#include <bits/stdc++.h>
using namespace std;
int n, q, tot, num, ver[1000005], nxt[1000005], head[500005], sz[500005],
    f[500005], sn[500005], dfn[500005], tp[500005], t[2000005];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = (x + (x << 2) << 1) + (ch ^ 48);
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
}
void add(int x, int y) { ver[++tot] = y, nxt[tot] = head[x], head[x] = tot; }
void dfs1(int x) {
  sz[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != f[x]) {
      f[y] = x, dfs1(y), sz[x] += sz[y];
      if (sz[y] > sz[sn[x]]) sn[x] = y;
    }
  }
}
void dfs2(int x) {
  dfn[x] = ++num;
  if (sn[x]) tp[sn[x]] = tp[x], dfs2(sn[x]);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != f[x] && y != sn[x]) tp[y] = y, dfs2(y);
  }
}
void psd(int i, int l, int r) {
  if (t[i] >= 0) t[i << 1] = t[i], t[i << 1 | 1] = t[i], t[i] = -1;
}
void mdf(int i, int l, int r, int x, int y, int z) {
  if (x <= l && y >= r) {
    t[i] = z;
    return;
  }
  psd(i, l, r);
  int mid = l + r >> 1;
  if (x <= mid) mdf(i << 1, l, mid, x, y, z);
  if (y > mid) mdf(i << 1 | 1, mid + 1, r, x, y, z);
}
int query(int i, int l, int r, int x) {
  if (l == r) return t[i];
  psd(i, l, r);
  int mid = l + r >> 1;
  if (x <= mid) return query(i << 1, l, mid, x);
  return query(i << 1 | 1, mid + 1, r, x);
}
void M(int x, int y) {
  while (x) mdf(1, 1, n, dfn[tp[x]], dfn[x], y), x = f[tp[x]];
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    add(x, y), add(y, x);
  }
  dfs1(1), tp[1] = 1, dfs2(1), q = read();
  while (q--) {
    int fl = read(), x = read();
    if (fl == 1) mdf(1, 1, n, dfn[x], dfn[x] + sz[x] - 1, 1);
    if (fl == 2) M(x, 0);
    if (fl == 3) write(query(1, 1, n, dfn[x])), putchar('\n');
  }
  return 0;
}
