#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif
using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
const int N = 2e5 + 5;
vector<int> tree(4 * N), lazy(4 * N), adj[N];
int n, q, arr[N], tin[N], tout[N], timer = 0;
void propagate(int node, int l, int r) {
if (lazy[node] == 0) return;
tree[node] = (r - l + 1) - tree[node];
if (l != r) {
lazy[node * 2] += lazy[node];
lazy[node * 2 + 1] += lazy[node];
}
lazy[node] = 0;
}
void update(int node, int start, int end, int l, int r) {
propagate(node, start, end);
if (start > r || end < l) return;
if (start >= l && end <= r) {
lazy[node] = (lazy[node] + 1) % 2;
propagate(node, start, end);
return;
}
int mid = (start + end) / 2;
update(node * 2, start, mid, l, r);
update(node * 2 + 1, mid + 1, end, l, r);
tree[node] = tree[node * 2] + tree[node * 2 + 1];
}
int query(int node, int start, int end, int l, int r) {
propagate(node, start, end);
if (start > r || end < l) return 0;
if (start >= l && end <= r) return tree[node];
int mid = (start + end) / 2;
int q1 = query(node * 2, start, mid, l, r);
int q2 = query(node * 2 + 1, mid + 1, end, l, r);
return q1 + q2;
}
void euler_tour(int now, int par) {
tin[now] = ++timer;
for (auto &it: adj[now]) {
if (it == par) continue;
euler_tour(it, now);
}
tout[now] = timer;
}
void shelby() {
cin >> n;
for (int i = 1; i <= n; ++i) cin >> arr[i];
for (int i = 1; i < n; ++i) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
euler_tour(1, -1);
for (int i = 1; i <= n; ++i) {
if (arr[i]) update(1, 1, n, tin[i], tin[i]);
}
int q;
cin >> q;
while (q--) {
int t, k;
cin >> t >> k;
if (t == 1) update(1, 1, n, tin[k], tout[k]);
else cout << query(1, 1, n, tin[k], tout[k]) << '\n';
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}