#include <bits/stdc++.h>
using namespace std;
int n, m, times;
int in[5000100], out[5000100], f[5000100], tree[5000100];
vector<int> g[5000100];
inline int read() {
  int res = 0, f = 1;
  char c;
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) res = (res << 1) + (res << 3) + (c ^ 48);
  return res * f;
}
inline void dfs(int u, int fa) {
  in[u] = ++times;
  f[u] = fa;
  int sz = g[u].size();
  for (int i = 0; i <= sz - 1; i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
  }
  out[u] = times;
}
inline void push_down(int rt) {
  if (tree[rt]) {
    tree[rt << 1] = tree[rt << 1 | 1] = tree[rt];
  }
}
inline void push_up(int rt) { tree[rt] = tree[rt << 1] & tree[rt << 1 | 1]; }
inline void update(int rt, int l, int r, int ql, int qr, int k) {
  if (ql <= l && qr >= r) {
    tree[rt] = k;
    return;
  }
  push_down(rt);
  int mid = (l + r) >> 1;
  if (ql <= mid) update(rt << 1, l, mid, ql, qr, k);
  if (qr > mid) update(rt << 1 | 1, mid + 1, r, ql, qr, k);
  push_up(rt);
}
inline int query(int rt, int l, int r, int ql, int qr) {
  if (ql <= l && qr >= r) return tree[rt];
  push_down(rt);
  int mid = (l + r) >> 1;
  int res = 1;
  if (ql <= mid) res = res & query(rt << 1, l, mid, ql, qr);
  if (qr > mid) res = res & query(rt << 1 | 1, mid + 1, r, ql, qr);
  return res;
}
int main() {
  n = read();
  for (register int i = 1; i < n; i++) {
    int u = read(), v = read();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  m = read();
  for (register int i = 1; i <= m; i++) {
    int op = read(), a = read();
    if (op == 1) {
      if (a > 1 && query(1, 1, n, in[a], out[a]) == 0) {
        update(1, 1, n, in[a], out[a], 1);
        update(1, 1, n, in[f[a]], in[f[a]], 0);
      } else
        update(1, 1, n, in[a], out[a], 1);
    }
    if (op == 2) update(1, 1, n, in[a], in[a], 0);
    if (op == 3) printf("%d\n", query(1, 1, n, in[a], out[a]));
  }
  return 0;
}
