// 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"
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) {
os << '{';
for (const auto &x : v) os << " " << x;
return os << '}';
}
const int N = 2e5 + 5;
int n;
vector<vector<int>> g(N);
vector<int> euler;
vector<int> startTime(N), endTime(N);
vector<int> lights(N);
int seg[4 * N], lazy[4 * N];
void dfs(int u, int par = 0){
startTime[u] = euler.size() + 1;
// cout << "dfs check " << u << ' ' << startTime[u] << endl;
euler.pb(u);
for(auto &v: g[u]){
if(v == par) continue;
dfs(v, u);
}
endTime[u] = euler.size();
// cout << endTime[u] << endl;
}
void build(int i, int l, int r){
if(l == r){
seg[i] = lights[euler[l-1]];
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] ^= 1;
lazy[(1<<i)+1] ^= 1;
}
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, end, 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, end, 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);
build(1, 1, n);
// for(int i=1 ; i<=10 ; i++){
// cout << seg[i] << ' ' ;
// }
// cout << endl;
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 ;
}