#include using namespace std; using ll = int_fast64_t; using ld = long double; #define int ll #define all(a) (a).begin(),(a).end() #define fs first #define sc second #define H pair #define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++) #define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++) #define req(n,i) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--) #define vec vector #define pb emplace_back constexpr int MXN = 500000 + 100; constexpr ll inf = 3 * 1e18; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } ll read() { ll u, k = scanf("%lld", &u); return u; } class LCA { int n; int table[MXN][25]; vec(*e)[MXN]; int dep[MXN]; public: void init(const int& size, vector(&f)[MXN]) { n = size; e = &f; for (int i = 0; i <= n; i++) for (int j = 0; j < 25; j++) table[i][j] = -1; } void build(const int& st) { dfs(st, -1, 0); for (int j = 0; j < 24; j++)for (int i = 0; i <= n; i++) { if (table[i][j] > -1) table[i][j + 1] = table[table[i][j]][j]; } } int get(int x, int y) { if (dep[x] > dep[y]) swap(x, y); for (int i = 24; i >= 0; i--) { if (((dep[y] - dep[x]) >> i) & 1) y = table[y][i]; } if (x == y) return x; for (int i = 24; i >= 0; i--) { if (table[x][i] != table[y][i]) { x = table[x][i], y = table[y][i]; } } return table[x][0]; } int operator[](const int& x) const { return dep[x]; } private: void dfs(int v, int p, int d) { table[v][0] = p; dep[v] = d; for (auto& to : (*e)[v]) { if (to != p) dfs(to, v, d + 1); } } }; int n, k, q; veca, c; int dp[200000]; LCA lca; int rr; vece[MXN]; int dat[400000]; void update(int x, int y) { x += rr - 1; dat[x] = y; while (x > 0) { x = (x - 1) / 2; dat[x] = dat[x * 2 + 1]; if (dat[x * 2 + 2] >= 0) dat[x] = lca.get(dat[x], dat[x * 2 + 2]); } } int query(int i, int a, int b, int l, int r) { if (b <= l || r <= a) return -1; if (a <= l && r <= b) return dat[i]; int x = query(i * 2 + 1, a, b, l, (l + r) / 2); int y = query(i * 2 + 2, a, b, (l + r) / 2, r); if (x < y) swap(x, y); if (x >= 0 && y >= 0) return lca.get(x, y); return x; } int query(int a, int b) { return query(0, a, b, 0, rr); } void dfs(int x, int p, int v) { dp[x] = v; for (auto g : e[x]) { dfs(g, x, max(v, c[g])); } } void solve() { cin >> n >> k >> q; a.clear(); c.clear(); rep(i, n) c.pb(read()); rep(i, k) a.pb(read() - 1); rep(i, n - 1) { int u, v; cin >> u >> v; u--; v--; e[v].pb(u); } rep(i, 400000) dat[i] = -1; lca.init(n, e); lca.build(0); rr = 1; while (rr < k) rr *= 2; rep(i, k) update(i, a[i]); dfs(0, -1, c[0]); while (q > 0) { q--; int t, x, y; cin >> t >> x >> y; if (t == 1) { x--; y--; a[x] = y; update(x, y); } else { x--; int r = query(x, y); cout << dp[r] << endl; } } } signed main() { solve(); }