#include <bits/stdc++.h>
using namespace std;
const int max_n = 500000;
int n;
vector<int> child[max_n];
int st[max_n], ed[max_n], clk;
void dfs(int pnd, int nd) {
  st[nd] = clk++;
  for (int j = 0; j < int(child[nd].size()); j++)
    if (child[nd][j] != pnd) dfs(nd, child[nd][j]);
  ed[nd] = clk;
}
int qfil[4 * max_n] = {0}, qclr[4 * max_n] = {0};
int rfil[4 * max_n] = {0}, rclr[4 * max_n] = {0};
void upd(int *qarr, int *rarr, int nd, int lb, int ub, int qval, int qlb,
         int qub) {
  if (lb == qlb && ub == qub) {
    qarr[nd] = max(qarr[nd], qval);
    rarr[nd] = max(rarr[nd], qval);
  } else {
    int lnd = 2 * nd + 1;
    int rnd = 2 * nd + 2;
    int md = (lb + ub) / 2;
    upd(qarr, rarr, lnd, lb, md, qarr[nd], lb, md);
    upd(qarr, rarr, rnd, md, ub, qarr[nd], md, ub);
    if (qlb < md) upd(qarr, rarr, lnd, lb, md, qval, qlb, min(md, qub));
    if (md < qub) upd(qarr, rarr, rnd, md, ub, qval, max(qlb, md), qub);
    rarr[nd] = max(rarr[lnd], rarr[rnd]);
  }
}
int calc(int *qarr, int *rarr, int nd, int lb, int ub, int qlb, int qub) {
  if (lb == qlb && ub == qub)
    return rarr[nd];
  else {
    int lnd = 2 * nd + 1;
    int rnd = 2 * nd + 2;
    int md = (lb + ub) / 2;
    upd(qarr, rarr, lnd, lb, md, qarr[nd], lb, md);
    upd(qarr, rarr, rnd, md, ub, qarr[nd], md, ub);
    int res = -1;
    if (qlb < md)
      res = max(res, calc(qarr, rarr, lnd, lb, md, qlb, min(md, qub)));
    if (md < qub)
      res = max(res, calc(qarr, rarr, rnd, md, ub, max(qlb, md), qub));
    rarr[nd] = max(rarr[lnd], rarr[rnd]);
    return res;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int v0, v1;
    scanf("%d %d", &v0, &v1);
    v0--;
    v1--;
    child[v0].push_back(v1);
    child[v1].push_back(v0);
  }
  clk = 0;
  dfs(-1, 0);
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int op, v;
    scanf("%d %d", &op, &v);
    v--;
    if (op == 1)
      upd(qfil, rfil, 0, 0, clk, i + 1, st[v], ed[v]);
    else if (op == 2)
      upd(qclr, rclr, 0, 0, clk, i + 1, st[v], st[v] + 1);
    else if (op == 3) {
      int afil = calc(qfil, rfil, 0, 0, clk, st[v], st[v] + 1);
      int aclr = calc(qclr, rclr, 0, 0, clk, st[v], ed[v]);
      if (afil < aclr)
        printf("0\n");
      else if (afil > aclr)
        printf("1\n");
      else
        printf("0\n");
    }
  }
  return 0;
}
