// PIPRA || HABIB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
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 N = 2e5 + 5;
int n;
vector<vector<int>> g(N);
vector<int> startTime(N), endTime(N), lights(N);
vector<int> seg(4 * N, 0), lazy(4 * N, 0);
vector<int> A(N);
int timer = 1;
void dfs(int u, int par = -1){
startTime[u] = timer;
timer++;
for(auto v: g[u]){
if(v == par) continue;
dfs(v, u);
}
endTime[u] = timer - 1;
}
void build(int i, int l, int r){
if(l == r){
seg[i] = lights[l];
return;
}
int li = (i << 1);
int ri = (i << 1) + 1;
int mid = (l + r) >> 1;
build(li, l, mid);
build(ri, mid+1, r);
seg[i] = seg[li] + seg[ri];
}
void lazyPropagate(int i, int start, int end){
if(lazy[i] != 0){
seg[i] = (end - start +1) - seg[i];
if(start != end){
lazy[1<<i] ^= lazy[i];
lazy[(1<<i)+1] ^= lazy[i];
}
lazy[i] = 0;
}
}
void update_range(int i, int l, int r, int start, int end){
lazyPropagate(i, l, r);
if(l > end or r < start) return;
if(l >= start and r <= end){
lazy[i] ^= 1;
lazyPropagate(i, l, r);
return;
}
int li = (i << 1);
int ri = (i << 1) + 1;
int mid = (l + r) >> 1;
update_range(li, l, mid, start, end);
update_range(ri, mid+1, r, start, end);
seg[i] = seg[li] + seg[ri];
}
int query(int i, int l, int r, int start, int end){
lazyPropagate(i, l, r);
if(l > end or r < start)
return 0;
if(l >= start and r <= end)
return seg[i];
int li = (i << 1);
int ri = (i << 1) + 1;
int mid = (l + r) >> 1;
return query(li, l, mid, start, end) +
query(ri, mid+1, r, start, end);
}
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);
for(int i=1 ; i<=n ; i++){
A[startTime[i]] = A[i];
}
build(1, 1, n);
int q; cin >> q;
while(q--){
int p, node;
cin >> p >> node;
if(p == 1){
update_range(1, 1, n, startTime[node], endTime[node]);
}
else{
cout << query(1, 1, n, startTime[node], endTime[node]) << endl;
}
}
}
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 ;
}