#include "bits/stdc++.h" using namespace std; #define int long long #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i) #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i) #define ALL(a) a.begin(), a.end() #define IN(a, x, b) (a <= x && x < b) templateinline void out(T t){cout << t << "\n";} templateinline void out(T t,Ts... ts){cout << t << " ";out(ts...);} templateinline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;} templateinline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;} constexpr int INF = 1e18; template struct SegmentTree{ using F = function; int n; F f; T ti; vector dat; SegmentTree(){}; SegmentTree(F f,T ti):f(f),ti(ti){} void init(int n_){ n=1; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ T vl=ti,vr=ti; for(int l=a+n,r=b+n;l>=1,r>>=1) { if(l&1) vl=f(vl,dat[l++]); if(r&1) vr=f(dat[--r],vr); } return f(vl,vr); } }; //auto f = [](){}; //auto seg = SegmentTree(f,Ti); template< typename T > struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; template< typename T > using Edges = vector< edge< T > >; template< typename T > using WeightedGraph = vector< Edges< T > >; using UnWeightedGraph = vector< vector< int > >; template< typename T > using Matrix = vector< vector< T > >; 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 getDep(int x){return dep[x];}; int getDist(int a,int b){ int parDepth = getDep(query(a,b)); return getDep(a)-parDepth+getDep(b)-parDepth; } 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]; } }; signed main(){ int N,K,Q; cin >> N >> K >> Q; vectorc(N); REP(i,N){ cin >> c[i]; } vectora(K); REP(i,K){ cin >> a[i]; --a[i]; } vector>g(N); REP(i,N - 1){ int a,b; cin >> a >> b; --a;--b; g[a].emplace_back(b); g[b].emplace_back(a); } DoublingLowestCommonAncestor>>lca(g); lca.build(); vectore(N); int cnt = 0; auto dfs = [&](auto&&f,int now,int par) -> int { e[now] = cnt++; if(par != -1)CHMAX(c[now],c[par]); for(auto e:g[now]){ if(e == par)continue; f(f,e,now); } }; dfs(dfs,0,-1); SegmentTreema([](int a,int b){return max(a,b);},0ll); SegmentTreemi([](int a,int b){return min(a,b);},INF); vectorv(K); REP(i,K){ v[i] = e[a[i]]; } ma.build(v); mi.build(v); vectorinv(N); REP(i,N){ inv[e[i]] = i; } vectorans; while(Q--){ int t; cin >> t; if(t == 1){ int x,y; cin >> x >> y; --x;--y; ma.set_val(x,e[y]); mi.set_val(x,e[y]); }else{ int l,r; cin >> l >> r; --l;--r; int mostR = ma.query(l,r + 1); int mostL = mi.query(l,r + 1); int par = lca.query(mostL,mostR); //out(mostL,mostR,par,c[par]); ans.emplace_back(c[inv[par]]); } } for(auto e:ans)out(e); }