#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; struct LCA{ vector<vector<int>> g; vector<int> d; vector<vector<int>> p; int log; int n; LCA(const vector<vector<int>> &g):n(g.size()), g(g), d(g.size()){ log=0; while(1<<log<=n) log++; p.resize(log, vector<int>(n)); } void dfs(int x, int prev){ for(auto y:g[x]){ if(y==prev) continue; d[y]=d[x]+1; p[0][y]=x; dfs(y, x); } } void build(){ dfs(0, -1); for(int i=1; i<log; i++){ for(int j=0; j<n; j++){ p[i][j]=p[i-1][p[i-1][j]]; } } } int lca(int a, int b){ if(d[a]>d[b]) swap(a, b); int dd=d[b]-d[a], i=0; int a1=a, b1=b; while(dd){ if(dd&1) b1=p[i][b1]; dd>>=1; i++; } if(a1==b1) return a1; for(int j=log-1; j>=0; j--){ if(p[j][a1]!=p[j][b1]){ a1=p[j][a1], b1=p[j][b1]; } } return p[0][a1]; } int dist(int a, int b){ return d[a]+d[b]-2*d[lca(a, b)]; } }; template<typename Monoid> struct SegmentTree{ using F=function<Monoid(Monoid, Monoid)>; int sz; vector<Monoid> seg; const F f; const Monoid e; SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){ sz=1; while(sz<n) sz<<=1; seg.resize(2*sz, e); } SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){ sz=1; while(sz<n) sz<<=1; seg.resize(2*sz, e); for(int i=0; i<n; i++) seg[i+sz]=v[i]; for(int i=sz-1; i>=1; i--){ seg[i]=f(seg[2*i], seg[2*i+1]); } } void update(int k, const Monoid &x){ k+=sz; seg[k]=x; while(k>1){ k>>=1; seg[k]=f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b){ a+=sz, b+=sz; Monoid ret=e; for(;a<b; a>>=1, b>>=1){ if(b&1) ret=f(ret, seg[--b]); if(a&1) ret=f(ret, seg[a++]); } return ret; } /*Monoid query(int a, int b){ //演算が非可換のとき a+=sz, b+=sz; Monoid retl=e, retr=e; for(;a<b; a>>=1, b>>=1){ if(b&1) retr=f(seg[--b], retr); if(a&1) retl=f(retl, seg[a++]); } return f(retl, retr); }*/ Monoid operator[](const int &k) const{ return seg[k+sz]; } }; int main() { int n, k, q; cin>>n>>k>>q; int c[100010]; for(int i=0; i<n; i++) cin>>c[i]; vector<vector<int>> g(n); vector<int> a(k); for(int i=0; i<k; i++){ cin>>a[i]; a[i]--; } for(int i=0; i<n-1; i++){ int e, f; cin>>e>>f; e--; f--; g[e].push_back(f); g[f].push_back(e); } int mx[100010]; mx[0]=c[0]; auto dfs=[&](auto dfs, int x, int p)->void{ for(auto y:g[x]){ if(y==p) continue; mx[y]=max(mx[x], c[y]); dfs(dfs, y, x); } }; dfs(dfs, 0, -1); LCA lca(g); lca.build(); int e=-1; auto f=[&](int x, int y){ if(x==-1) return y; else if(y==-1) return x; else return lca.lca(x, y); }; SegmentTree<int> seg(k, f, e, a); while(q--){ int t; cin>>t; if(t==1){ int x, y; cin>>x>>y; x--; y--; seg.update(x, y); }else{ int l, r; cin>>l>>r; l--; cout<<mx[seg.query(l, r)]<<endl; } } return 0; }