#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 1e4;
int n, ST[maxn], FT[maxn], seg[4 * maxn], SegR[4 * maxn], Time = 1;
vector<int> adj[maxn];
bool mark[maxn];
void DFS_ST_FT(int v) {
  mark[v] = true;
  ST[v] = Time++;
  for (int i = 0; i < adj[v].size(); i++)
    if (!mark[adj[v][i]]) DFS_ST_FT(adj[v][i]);
  FT[v] = Time;
}
void input() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  DFS_ST_FT(1);
}
void Add(int l, int r, int value, int s, int e, int id) {
  if (e <= l || r <= s) return;
  if (l <= s && e <= r) {
    seg[id] = value;
    return;
  }
  int mid = (s + e) / 2;
  Add(l, r, value, s, mid, (id * 2));
  Add(l, r, value, mid, e, (id * 2 + 1));
}
int GLF(int pos, int s, int e, int id) {
  if (e - s == 1) return seg[id];
  int mid = (s + e) / 2;
  if (pos < mid)
    return max(seg[id], GLF(pos, s, mid, (id * 2)));
  else
    return max(seg[id], GLF(pos, mid, e, (id * 2 + 1)));
}
void Remove(int pos, int value, int s, int e, int id) {
  SegR[id] = value;
  if (e - s == 1) return;
  int mid = (s + e) / 2;
  if (pos < mid)
    Remove(pos, value, s, mid, (id * 2));
  else
    Remove(pos, value, mid, e, (id * 2 + 1));
}
int GLR(int l, int r, int s, int e, int id) {
  if (e <= l || r <= s) return 0;
  if (l <= s && e <= r) return SegR[id];
  int mid = (s + e) / 2;
  return max(GLR(l, r, s, mid, (id * 2)), GLR(l, r, mid, e, (id * 2 + 1)));
}
void queries() {
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int t, v;
    cin >> t >> v;
    if (t == 1) Add(ST[v], FT[v], i, 1, n + 1, 1);
    if (t == 2) Remove(ST[v], i, 1, n + 1, 1);
    if (t == 3) {
      if (GLF(ST[v], 1, n + 1, 1) > GLR(ST[v], FT[v], 1, n + 1, 1))
        cout << 1 << endl;
      else
        cout << 0 << endl;
    }
  }
}
int main() {
  input();
  queries();
  return 0;
}
