import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline class LCA_wp(): def __init__(self,e,w=None,f=None,ide_ele=None ,root=0): if w is None: self.N = len(e) self.e = e self.root = root self.IN = [-1]*N self.OUT = [-1]*N self.DIST = [-1]*N self.time = 0 self.DIST[root] = 0 self.parents = [-1]*N self.dfs(root) self.depth = [(self.DIST[i],i) for i in range(N)] self.init_val = [-1]*(2*N) for i in range(N): x = self.IN[i] y = self.OUT[i] self.init_val[x] = self.depth[i] self.init_val[y] = self.depth[self.parents[i]] self.T = self.SegTree(self.init_val) return self.N = len(e) self.e = e self.root = root self.IN = [-1]*N self.OUT = [-1]*N self.DIST = [-1]*N self.time = 0 self.DIST[root] = 0 self.parents = [-1]*N self.init_val_w = [ide_ele]*(2*N) self.dfs(root) self.depth = [(self.DIST[i],i) for i in range(N)] self.init_val = [-1]*(2*N) for i in range(N): x = self.IN[i] y = self.OUT[i] self.init_val[x] = self.depth[i] self.init_val[y] = self.depth[self.parents[i]] for i in range(N): self.init_val_w[self.IN[i]] = w[i] self.W = self.SegTree(self.init_val_w,f,ide_ele) self.T = self.SegTree(self.init_val) return def weight_update(self,x,y): self.W.update(x,y) return def tree_query(self,x): return self.W.query(self.IN[x],self.OUT[x]) def dfs(self,x): self.IN[x] = self.time self.time += 1 for ix,c in e[x]: if self.DIST[ix] != -1: continue self.parents[ix] = x self.DIST[ix] = self.DIST[x] + c self.dfs(ix) self.OUT[x] = self.time self.time += 1 def lca(self,l,r): L = self.IN[l] R = self.IN[r] if R 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def query(self, l, r): """ [l, r)のsegfuncしたものを得る l: index(0-index) r: index(0-index) """ res = self.ide_ele l += self.num r += self.num while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: res = self.segfunc(res, self.tree[r - 1]) l >>= 1 r >>= 1 return res class SegTree: """ Segment Tree """ def __init__(self, init_val, segfunc, ide_ele): """ 初期化 init_val: 配列の初期値 """ n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num # 配列の値を葉にセット for i in range(n): self.tree[self.num + i] = init_val[i] # 構築していく for i in range(self.num - 1, 0, -1): self.tree[i] = segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): """ k番目の値をxに更新 k: index(0-index) x: update value """ k += self.num self.tree[k] = x while k > 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def query(self, l, r): """ [l, r)のsegfuncしたものを得る l: index(0-index) r: index(0-index) """ res = self.ide_ele l += self.num r += self.num while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: res = self.segfunc(res, self.tree[r - 1]) l >>= 1 r >>= 1 return res N,K,Q = map(int,input().split()) C = list(map(int,input().split())) A = list(map(int,input().split())) A = [i-1 for i in A] e = [[] for _ in range(N)] for _ in range(N-1): a,b = map(int,input().split()) a -= 1 b -= 1 e[a].append((b,1)) e[b].append((a,1)) L = LCA_wp(e) ide_ele_0 = (10**10,-1) segfunc_0 = lambda x,y:min(x,y) init_0 = [ide_ele_0 for _ in range(K)] for i in range(K): init_0[i] = (L.IN[A[i]],A[i]) mT = SegTree(init_0,segfunc_0,ide_ele_0) ide_ele_1 = (-1,-1) segfunc_1 = lambda x,y:max(x,y) init_1 = [ide_ele_1 for _ in range(K)] for i in range(K): init_1[i] = (L.IN[A[i]],A[i]) MT = SegTree(init_1,segfunc_1,ide_ele_1) W = [-1]*N W[0] = C[0] def dfs(x): for ix,c in e[x]: if W[ix] != -1: continue W[ix] = max(C[ix],W[x]) dfs(ix) dfs(0) for _ in range(Q): t,x,y = map(int,input().split()) x -= 1 y -= 1 if t == 1: mT.update(x,(L.IN[y],y)) MT.update(x,(L.IN[y],y)) else: l = mT.query(x,y+1)[1] r = MT.query(x,y+1)[1] p = L.lca(l,r) print(W[p])