#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int mxN = 5e5 + 5, mxM = 1e4 + 5;
const int mod = 1e9 + 7, inf = 1e9;
const long long linf = 1e18;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
int n, q;
vector<int> g[mxN];
int tin[mxN], tout[mxN], timer;
void dfs(int v = 1, int p = -1) {
  tin[v] = ++timer;
  for (int to : g[v])
    if (p != to) dfs(to, v);
  tout[v] = timer;
}
struct seg {
  int t[mxN * 4], lz[mxN * 4];
  void push(int v, int tl, int tr) {
    if (!lz[v]) return;
    if (tl != tr) {
      lz[v * 2] = lz[v * 2 + 1] = lz[v];
    }
    t[v] = lz[v];
    lz[v] = 0;
  }
  void upd(int l, int r, int x, int v, int tl, int tr) {
    push(v, tl, tr);
    if (tr < l || r < tl) return;
    if (l <= tl and tr <= r) {
      lz[v] = x;
      push(v, tl, tr);
      return;
    }
    upd(l, r, x, v * 2, tl, (tl + tr) / 2);
    upd(l, r, x, v * 2 + 1, (tl + tr) / 2 + 1, tr);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
  }
  int get(int l, int r, int v = 1, int tl = 1, int tr = timer) {
    push(v, tl, tr);
    if (tr < l || r < tl) return 0;
    if (l <= tl and tr <= r) return t[v];
    return max(get(l, r, v * 2, tl, (tl + tr) / 2),
               get(l, r, v * 2 + 1, (tl + tr) / 2 + 1, tr));
  }
} t1, t2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int l, r;
    cin >> l >> r;
    g[l].push_back(r), g[r].push_back(l);
  }
  dfs();
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    int type, v;
    cin >> type >> v;
    if (type == 1) {
      t1.upd(tin[v], tout[v], i, 1, 1, n);
    } else if (type == 2) {
      t2.upd(tin[v], tin[v], i, 1, 1, n);
    } else {
      int tt1 = t1.get(tin[v], tin[v], 1, 1, n);
      int tt2 = t2.get(tin[v], tout[v], 1, 1, n);
      cout << (tt1 > tt2) << '\n';
    }
  }
  return 0;
}
