#include <bits/stdc++.h>
using namespace std;
void dfs(int node,vector<vector<int>> &adj,vector<int> &s,vector<int> &light){
if(light[node] == 1){
s.push_back(node);
}
for(int t : adj[node]){
dfs(t,adj,s,light);
}
}
void toggle(int node,vector<vector<int>> &adj,vector<int> &light){
if(light[node] == 1){
light[node] = 0;
}else{
light[node] = 1;
}
for(int t : adj[node]){
toggle(t,adj,light);
}
}
int main()
{
int n;
cin >> n;
vector<int> light(n+1);
for(int i = 1; i <= n; i++){
int c;
cin >> c;
light[i] = c;
}
vector<vector<int>> adj(n+1);
for(int i = 0; i < n-1; i++){
int a,b;
cin >> a >> b;
adj[a].push_back(b);
}
int q;
cin >> q;
for(int i = 0; i < q; i++){
int a,b;
cin >> a >> b;
if(a == 2){
vector<int> s;
dfs(b,adj,s,light);
cout << s.size() << endl;
}else{
toggle(b,adj,light);
}
}
}