#include using i32 = int_fast32_t; using i64 = int_fast64_t; using u32 = uint_fast32_t; using u64 = uint_fast64_t; using f64 = double; using f80 = long double; #define FOR(v, a, b) for(i64 v = (a); v < (b); ++v) #define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v) #define REP(v, n) FOR(v, 0, n) #define REPE(v, n) FORE(v, 0, n) #define REV(v, a, b) for(i64 v = (a); v >= (b); --v) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it) #define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it) #define EXIST(c,x) ((c).find(x) != (c).end()) #define fst first #define snd second #define UNIQ(v) (v).erase(unique(ALL(v)), (v).end()) #define bit(i) (1LL<<(i)) #ifdef DEBUG #include #else #define dump(...) ((void)0) #endif using namespace std; template void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost< istream& operator>>(istream &is, vector &v){for(auto &a : v) is >> a; return is;} template void pout(const T &value){std::cout << value << "\n";} template void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);} template bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);} template bool chmax(T &a, const U &b){return (a void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);} template auto make_vector(int n, int m, const T &value){return vector>(n, vector(m, value));} struct Init{ Init(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); cerr << fixed << setprecision(12); } }init; template class Edge{ public: int from,to; Cost cost; Edge() {} Edge(int to, Cost cost): to(to), cost(cost){} Edge(int from, int to, Cost cost): from(from), to(to), cost(cost){} Edge rev() const {return Edge(to,from,cost);} friend std::ostream& operator<<(std::ostream &os, const Edge &e){ os << "(FROM: " << e.from << "," << "TO: " << e.to << "," << "COST: " << e.cost << ")"; return os; } }; template using Graph = std::vector>>; template using Tree = std::vector>>; template void add_edge(C &g, int from, int to, T w){ g[from].emplace_back(from, to, w); } template void add_undirected(C &g, int a, int b, T w){ add_edge(g, a, b, w); add_edge(g, b, a, w); } template class HLDecomposition{ Tree tree; int n; std::vector sub, // subtree size par, // parent id head, // chain head id id, // id[original id] = hld id rid, // rid[hld id] = original id next, // next node in a chain end; // int dfs_sub(int cur, int p){ par[cur] = p; int t = 0; for(auto &e : tree[cur]){ if(e.to == p) continue; sub[cur] += dfs_sub(e.to, cur); if(sub[e.to] > t){ t = sub[e.to]; next[cur] = e.to; std::swap(e, tree[cur][0]); } } return sub[cur]; } void dfs_build(int cur, int &i){ id[cur] = i; rid[i] = cur; ++i; for(auto &e : tree[cur]){ if(e.to == par[cur]) continue; head[e.to] = (e.to == tree[cur][0].to ? head[cur] : e.to); dfs_build(e.to, i); } end[cur] = i; } public: HLDecomposition(const Tree &tree, int root): tree(tree), n(tree.size()), sub(n,1), par(n,-1), head(n), id(n), rid(n), next(n,-1), end(n,-1){ dfs_sub(root, -1); int i = 0; dfs_build(root, i); } template // std::function void path_query_vertex(int x, int y, const Func &f) const { while(1){ if(id[x] > id[y]) std::swap(x, y); f(std::max(id[head[y]], id[x]), id[y]+1); if(head[x] == head[y]) return; y = par[head[y]]; } } template void path_query_vertex(int x, int y, const LeftFunc &f, const RightFunc &g) const { const int w = lca(x, y); path_query_vertex(x, w, f); x = y; y = w; while(1){ if(id[x] > id[y]){ std::swap(x, y); } g(std::max({id[head[y]], id[x], id[w]+1}), id[y]+1); if(head[x] == head[y]) return; y = par[head[y]]; } } template // std::function void path_query_edge(int x, int y, const Func &f) const { while(1){ if(id[x] > id[y]) std::swap(x, y); if(head[x] == head[y]){ if(x != y) f(id[x]+1, id[y]+1); return; } f(id[head[y]], id[y]+1); y = par[head[y]]; } } template // std::function void subtree_query_edge(int x, const Func &f) const { f(id[x]+1, end[x]); } template // std::function void subtree_query_vertex(int x, const Func &f) const { f(id[x], end[x]); } int get_edge_id(int u, int v) const { // 辺に対応するid if(par[u] == v){ return id[u]; }else if(par[v] == u){ return id[v]; } return -1; } int parent(int x) const {return par[x];}; int lca(int u, int v) const { while(1){ if(id[u] > id[v]) std::swap(u, v); if(head[u] == head[v]) return u; v = par[head[v]]; } } int get_id(int x) const { return id[x]; } }; template class SegmentTree{ using value_type = typename Monoid::value_type; int depth, size, hsize; std::vector data; public: SegmentTree(){} SegmentTree(int n): depth(n > 1 ? 32-__builtin_clz(n-1) + 1 : 1), size(1 << depth), hsize(size / 2), data(size, Monoid::id()) {} inline auto operator[](int i) const {return at(i);} inline auto at(int i) const {return data[hsize + i];} inline auto get(int x, int y) const { // [x,y) value_type ret_left = Monoid::id(); value_type ret_right = Monoid::id(); int l = x + hsize, r = y + hsize; while(l < r){ if(r & 1) ret_right = Monoid::op(data[--r], ret_right); if(l & 1) ret_left = Monoid::op(ret_left, data[l++]); l >>= 1, r >>= 1; } return Monoid::op(ret_left, ret_right); } inline void update(int i, const value_type &x){ i += hsize; data[i] = x; while(i > 1) i >>= 1, data[i] = Monoid::op(data[i << 1 | 0], data[i << 1 | 1]); } template inline void init_with_vector(const std::vector &val){ data.assign(size, Monoid::id()); for(int i = 0; i < (int)val.size(); ++i) data[hsize + i] = val[i]; for(int i = hsize-1; i >= 1; --i) data[i] = Monoid::op(data[i << 1 | 0], data[i << 1 | 1]); } template inline void init(const T &val){ init_with_vector(std::vector(hsize, val)); } }; template struct MaxMonoid{ using value_type = T; constexpr inline static value_type id(){return std::numeric_limits::lowest();} constexpr inline static value_type op(const value_type &a, const value_type &b){return std::max(a, b);} }; template struct MaybeMonoid{ using value_type = optional; static value_type id(){return {};} static value_type op(const value_type &a, const value_type &b){ if(not a) return b; if(not b) return a; return {Semigroup::op(*a, *b)}; } }; struct Semigroup{ using value_type = int; static std::function f; static value_type op(const value_type &a, const value_type &b){ return f(a, b); } }; std::function Semigroup::f; int main(){ int N, K, Q; cin >> N >> K >> Q; vector C(N); cin >> C; vector A(K); cin >> A; REP(i,K) A[i] -= 1; Tree tree(N); REP(i,N-1){ int e, f; cin >> e >> f; --e, --f; add_edge(tree, f, e, 1); } HLDecomposition hld(tree, 0); Semigroup::f = [&](int a, int b) -> int{ return hld.lca(a, b); }; SegmentTree> seg1(N); REP(i,N){ seg1.update(hld.get_id(i), C[i]); } SegmentTree> seg2(K); seg2.init_with_vector(A); while(Q--){ int T; cin >> T; if(T == 1){ int X, Y; cin >> X >> Y; --X; --Y; seg2.update(X, Y); }else{ int L, R; cin >> L >> R; int lca = *seg2.get(L-1, R); int ans = 0; hld.path_query_vertex(0, lca, [&](int l, int r){chmax(ans, seg1.get(l, r));}); pout(ans); } } return 0; }