#include using namespace std; #define int long long templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> Tree; Tree tree(100010); template< typename G > struct DoublingLowestCommonAncestor { const int LOG; vector< int > dep; const G &g; vector< vector< int > > table; DoublingLowestCommonAncestor(const G &g) : g(g), dep(g.size()), LOG(32 - __builtin_clz(g.size())) { table.assign(LOG, vector< int >(g.size(), -1)); } void dfs(int idx, int par, int d) { table[0][idx] = par; dep[idx] = d; for(auto &to : g[idx]) { if(to != par) dfs(to, idx, d + 1); } } void build() { dfs(0, -1, 0); for(int k = 0; k + 1 < LOG; k++) { for(int i = 0; i < table[k].size(); i++) { if(table[k][i] == -1) table[k + 1][i] = -1; else table[k + 1][i] = table[k][table[k][i]]; } } } int query(int u, int v) { if(dep[u] > dep[v]) swap(u, v); for(int i = LOG - 1; i >= 0; i--) { if(((dep[v] - dep[u]) >> i) & 1) v = table[i][v]; } if(u == v) return u; for(int i = LOG - 1; i >= 0; i--) { if(table[i][u] != table[i][v]) { u = table[i][u]; v = table[i][v]; } } return table[0][u]; } }; template struct SegmentTree{ using Func = function; int size; vector seg; const Func merge; const Monoid def; SegmentTree(int n, Monoid d, const Func f): merge(f), def(d){ for(size = 1; size <= n; size <<= 1); seg.assign(size*2, def); } Monoid& operator[] (int i) { return seg[i+size]; }; void build(){ for(int i = size-1;i >= 0;i--) seg[i] = merge(seg[i*2], seg[i*2+1]); } void update(int i, Monoid val){ seg[i += size] = val; while(i >>= 1) seg[i] = merge(seg[i*2], seg[i*2+1]); } void add(int i, Monoid val){ update(i, val+seg[i+size]); } Monoid get(int a, int b){ Monoid l = def, r = def; for(a += size, b += size; a < b; a >>= 1, b >>= 1){ if(a & 1) l = merge(l, seg[a++]); if(b & 1) r = merge(seg[--b], r); } return merge(l, r); } }; void dfs(int idx, int par){ for(auto e : tree[idx]){ if(e != par){ chmax(c[e], c[idx]); dfs(e, idx); } } } DoublingLowestCommonAncestor lca(tree); int m(int a, int b){ if(a == -1) return b; if(b == -1) return a; return lca.query(a, b); } signed main(){ cin >> n >> k >> q; for(int i = 0;i < n;i++){ cin >> c[i]; } for(int i = 0;i < k;i++){ cin >> a[i]; a[i]--; } for(int i = 0;i < n-1;i++){ int a, b; cin >> a >> b; a--; b--; tree[a].push_back(b); tree[b].push_back(a); } dfs(0, -1); lca.build(); SegmentTree seg(k, -1, m); for(int i = 0;i < k;i++){ seg.update(i, a[i]); } for(int i = 0;i < q;i++){ int t, x, y; cin >> t >> x >> y; if(t == 1){ seg.update(x-1, y-1); }else{ cout << c[seg.get(x-1, y)] << endl; } } return 0; }