#include <bits/stdc++.h>
#define y1 theboatman
#define make_struct(args...) {args}
using namespace std;
vector <int> tin, tout;
vector <vector <int> > g, up;
int timer;
void dfs(int v, int from) {
tin[v] = timer++;
up[v][0] = from;
for(int i = 1; i < 20; i++) {
up[v][i] = up[up[v][i - 1]][i - 1];
}
for(auto to : g[v]) {
if (to != from) {
dfs(to, v);
}
}
tout[v] = timer++;
}
bool upper(int a, int b) {
return (tin[a] <= tin[b] && tout[a] >= tout[b]);
}
int lca(int a, int b) {
if (upper(a, b)) {
return a;
}
if (upper(a, b)) {
return b;
}
for(int i = 19; i > -1; i--) {
if (!upper(up[a][i], b)) {
a = up[a][i];
}
}
return up[a][0];
}
int main() {
cin.tie(0);
ios :: sync_with_stdio(0);
int n, m, q;
cin >> n >> m >> q;
g.resize(n + 1);
for(int i = 1; i < n; i++) {
int x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
vector <int> a(m + 1);
for(int i = 1; i <= m; i++) {
cin >> a[i];
}
tin.resize(n + 1);
tout.resize(n + 1);
up.resize(n + 1, vector <int> (20, 1));
dfs(1, 1);
for(int it = 0; it < q; it++) {
int type;
cin >> type;
if (type == 1) {
int pos, v;
cin >> pos >> v;
a[pos] = v;
}
else {
int l, r, v;
cin >> l >> r >> v;
int L = -1, R = -1;
int mn = tin[v], mx = tout[v];
for(int i = l; i <= r; i++) {
if (mn <= tin[a[i]] && tin[a[i]] <= mx) {
int start = i;
int x = i, y = i;
while(i <= r && mn <= tin[a[i]] && tin[a[i]] <= mx) {
if (tin[a[i]] < tin[a[x]]) {
x = i;
}
if (tout[a[i]] > tout[a[y]]) {
y = i;
if (lca(a[x], a[y]) == v) {
L = start, R = i;
}
}
}
cout << L << " " << R << "\n";
}
}
return 0;
}
/*
*/
Compilation message
treearray.cpp: In function 'int main()':
treearray.cpp:120:1: error: expected '}' at end of input
}
^
treearray.cpp:120:1: error: expected '}' at end of input