// PIPRA || HABIB
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define endl "\n"
const int MAXN = 2e5 + 5;
int N, Q;
vector<int> g[MAXN], euler, in_time(MAXN), out_time(MAXN);
vector<int> lights(MAXN);
vector<int> seg(4 * MAXN), lazy(4 * MAXN);
void dfs(int node, int parent) {
in_time[node] = euler.size();
euler.pb(node);
for (int child : g[node]) {
if (child != parent) {
dfs(child, node);
}
}
out_time[node] = euler.size() - 1;
}
void build(int node, int start, int end) {
if (start == end) {
seg[node] = lights[euler[start]];
} else {
int mid = (start + end) / 2;
build(2 * node, start, mid);
build(2 * node + 1, mid + 1, end);
seg[node] = seg[2 * node] + seg[2 * node + 1];
}
}
void propagate(int node, int start, int end) {
if (lazy[node] != 0) {
seg[node] = (end - start + 1) - seg[node];
if (start != end) {
lazy[2 * node] ^= lazy[node];
lazy[2 * node + 1] ^= lazy[node];
}
lazy[node] = 0;
}
}
void update_range(int node, int start, int end, int l, int r) {
propagate(node, start, end);
if (start > end || start > r || end < l) return;
if (start >= l && end <= r) {
lazy[node] ^= 1;
propagate(node, start, end);
return;
}
int mid = (start + end) / 2;
update_range(2 * node, start, mid, l, r);
update_range(2 * node + 1, mid + 1, end, l, r);
seg[node] = seg[2 * node] + seg[2 * node + 1];
}
int query_range(int node, int start, int end, int l, int r) {
propagate(node, start, end);
if (start > end || start > r || end < l) return 0;
if (start >= l && end <= r) return seg[node];
int mid = (start + end) / 2;
return query_range(2 * node, start, mid, l, r) + query_range(2 * node + 1, mid + 1, end, l, r);
}
void pipra(){
cin >> N;
for (int i = 1; i <= N; ++i) {
cin >> lights[i];
}
for (int i = 1; i < N; ++i) {
int u, v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
dfs(1, -1);
build(1, 0, N - 1);
cin >> Q;
while (Q--) {
int type, k;
cin >> type >> k;
if (type == 1) {
update_range(1, 0, N - 1, in_time[k], out_time[k]);
} else {
cout << query_range(1, 0, N - 1, in_time[k], out_time[k]) << "\n";
}
}
}
int32_t main(){
// HABIB
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
// int t; cin>>t;
// while(t--) {
pipra();
// }
return 0 ;
}