#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 233;
int head[N];
struct Edge {
  int v, next;
} edge[N << 1];
int L[N], R[N];
int cnt, e;
void Add(int u, int v) {
  edge[e].v = v;
  edge[e].next = head[u];
  head[u] = e++;
}
void dfs(int u, int fa) {
  L[u] = ++cnt;
  for (int i = head[u]; ~i; i = edge[i].next) {
    if (edge[i].v == fa) continue;
    dfs(edge[i].v, u);
  }
  R[u] = cnt;
}
struct seg {
  int flag[N << 2], ma[N << 2];
  void go(int rt, int val) { ma[rt] = flag[rt] = val; }
  void pushdown(int rt) {
    if (flag[rt]) {
      go(rt << 1, flag[rt]);
      go(rt << 1 | 1, flag[rt]);
      flag[rt] = 0;
    }
  }
  void pushup(int rt) { ma[rt] = max(ma[rt << 1], ma[rt << 1 | 1]); }
  void build(int rt, int l, int r) {
    flag[rt] = 0;
    ma[rt] = 0;
    if (l != r) {
      int mid = l + r >> 1;
      build(rt << 1, l, mid);
      build(rt << 1 | 1, mid + 1, r);
    }
  }
  void update(int rt, int l, int r, int s, int e, int val) {
    if (s <= l && r <= e)
      go(rt, val);
    else {
      pushdown(rt);
      int mid = l + r >> 1;
      if (s <= mid) update(rt << 1, l, mid, s, e, val);
      if (e > mid) update(rt << 1 | 1, mid + 1, r, s, e, val);
      pushup(rt);
    }
  }
  int query(int rt, int l, int r, int s, int e) {
    if (s <= l && r <= e)
      return ma[rt];
    else {
      pushdown(rt);
      int mid = l + r >> 1;
      int m1 = 0, m2 = 0;
      if (s <= mid) m1 = query(rt << 1, l, mid, s, e);
      if (e > mid) m2 = query(rt << 1 | 1, mid + 1, r, s, e);
      pushup(rt);
      return max(m1, m2);
    }
  }
} t1, t2;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(head, -1, sizeof(head));
    e = 0;
    cnt = 0;
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      scanf("%d%d", &a, &b);
      Add(a, b), Add(b, a);
    }
    dfs(1, 0);
    t1.build(1, 1, cnt);
    t2.build(1, 1, cnt);
    int m;
    scanf("%d", &m);
    for (int i = 1; i <= m; ++i) {
      int op, x;
      scanf("%d%d", &op, &x);
      if (op == 1)
        t1.update(1, 1, cnt, L[x], R[x], i);
      else if (op == 2)
        t2.update(1, 1, cnt, L[x], L[x], i);
      else {
        int m1 = t1.query(1, 1, cnt, L[x], L[x]);
        int m2 = t2.query(1, 1, cnt, L[x], R[x]);
        if (m1 > m2)
          puts("1");
        else
          puts("0");
      }
    }
  }
  return 0;
}
