#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fast ios::sync_with_stdio(false); cin.tie(nullptr)
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
const int MAXN = 2e5 + 5;
int N, Q;
vi adj[MAXN], euler, start_time(MAXN), end_time(MAXN);
vi lights(MAXN);
vll seg(4 * MAXN), lazy(4 * MAXN);
void dfs(int node, int parent) {
start_time[node] = euler.size();
// cout << "dfs check " << node << ' ' << start_time[node] << endl;
euler.pb(node);
for (int child : adj[node]) {
if (child != parent) {
dfs(child, node);
}
}
end_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];
}
ll 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);
}
int main() {
fast;
cin >> N;
for (int i = 0; i < N; ++i) {
cin >> lights[i + 1];
}
for (int i = 0; i < N - 1; ++i) {
int u, v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
dfs(1, -1);
build(1, 0, N - 1);
// for(int i=0 ; i<=12 ; i++){
// cout << seg[i] << ' ';
// }
// cout << endl;
cin >> Q;
while (Q--) {
int type, k;
cin >> type >> k;
if (type == 1) {
update_range(1, 0, N - 1, start_time[k], end_time[k]);
} else {
cout << query_range(1, 0, N - 1, start_time[k], end_time[k]) << "\n";
}
}
return 0;
}