/*
* Copyright (c) 2024 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int a[200005],first[200005],last[200005];
vector<int> g[200005],tour;
int ind=0;
void eulertour(int node,int par)
{
first[node] = ind++;
tour.push_back(a[node]);
for(auto e:g[node])
{
if(e==par) continue;
eulertour(e,node);
}
last[node] = ind-1;
//tour.push_back(a[node]);
}
struct SGtreeLazy{
ll sg[800005],lazy[800005];
void build(int node,int start,int end)
{
if(start == end)
{
sg[node] = tour[end];
return;
}
int mid = (start+end)/2;
build(node*2,start,mid);
build(node*2+1,mid+1,end);
sg[node] = sg[node*2]+sg[node*2+1];
}
void push_lazy(int node,int start,int end)
{
if(lazy[node])
{
//sg[node] = sg[node] + (end-start+1)*lazy[node];
sg[node] = (end-start+1) - sg[node];
if(start != end)
{
lazy[node*2] ^= lazy[node];
lazy[node*2+1] ^= lazy[node];
}
lazy[node] = 0;
}
}
void rangeupdate(ll node,ll start,ll end,ll l,ll r,ll val)
{
push_lazy(node,start,end);
if(l>r || l>end || start>r) return;
if(l<=start && r>=end)
{
lazy[node] ^= val;
push_lazy(node,start,end);
return;
}
int mid = (start+end)/2;
rangeupdate(node*2,start,mid,l,r,val);
rangeupdate(node*2+1,mid+1,end,l,r,val);
sg[node] = sg[node*2] + sg[node*2+1];
}
ll query(ll node,ll start,ll end,ll l,ll r)
{
push_lazy(node,start,end);
if(l>end || start>r) return 0;
if(l<=start && r>=end) return sg[node];
ll mid = (start+end)/2;
ll q1 = query(node*2,start,mid,l,r);
ll q2 = query(node*2+1,mid+1,end,l,r);
sg[node] = sg[node*2]+sg[node*2+1];
return q1+q2;
}
} lazy;
int main()
{
int n; cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<n;i++)
{
int u,v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
eulertour(1,0);
//for(auto e:tour) cout<<e<<" "; cout<<endl;
lazy.build(1,0,ind-1);
int q; cin >> q;
while(q--)
{
int choice,k; cin >> choice >> k;
if(choice == 1)
{
lazy.rangeupdate(1,0,ind-1,first[k],last[k],1);
}
else
{
cout<<lazy.query(1,0,ind-1,first[k],last[k])<<endl;
}
}
}