#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0;
  bool flg = false;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') flg = true;
  for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
  return flg ? -x : x;
}
const int S = 888;
int n, K, q;
vector<int> g[100010];
vector<pair<int, int> > e[100010];
int c[100010];
struct D {
  int o, x, y;
} d[100010];
bool mrk[100010];
int rt[100010];
int dp[100010][2];
vector<int> H[100010];
int mn[100010], mx[100010];
int b[100010];
void predfs(int x, int f) {
  if (~c[x]) return;
  int L = 0;
  for (const auto &y : g[x])
    if (y ^ f) {
      predfs(y, x);
      L = max(L, int(g[y].size()) - 1);
    }
  mn[x] = -L, mx[x] = L;
  H[x].resize(L + 1 << 1);
}
inline int geth(const vector<int> &H, int mn, int mx, int w,
                const int p = -1e9) {
  int z = w;
  for (int i(H.size() - 1), _i(0); i >= _i; i--) {
    z = max(z, min(mn + i, w + H[i] + (int(i <= p) << 1)));
  }
  return z;
}
int dfn[100010];
void dfs0(int x, int f) {
  int tot = 0, lst = -1, z = -1;
  for (const auto &y : g[x])
    if (y ^ f) {
      dfs0(y, x);
      if (rt[y]) ++tot, lst = rt[y], z = y;
    }
  auto &H = ::H[x];
  fill((H).begin(), (H).end(), 0);
  const int &mn = ::mn[x], &mx = ::mx[x];
  int &b = ::b[x];
  b = 0;
  if (mrk[x] || tot >= 2) {
    dfn[++*dfn] = x;
    rt[x] = x;
    e[x].clear();
    for (const auto &y : g[x])
      if (y ^ f)
        if (rt[y]) e[x].emplace_back(rt[y], y);
    if (~c[x]) return;
    for (const auto &y : g[x])
      if (y ^ f && !rt[y]) {
        if (~c[y])
          b += c[y] ? 1 : -1;
        else
          H[dp[y][0] - mn] += 2, b--;
      }
    for (int i(H.size() - 2), _i(0); i >= _i; i--) H[i] += H[i + 1];
  } else {
    if (tot == 1) {
      rt[x] = lst;
      for (const auto &y : g[x])
        if (y ^ f && !rt[y]) {
          if (~c[y])
            b += c[y] ? 1 : -1;
          else
            H[dp[y][0] - mn] += 2, b--;
        }
      for (int i(H.size() - 2), _i(0); i >= _i; i--) H[i] += H[i + 1];
      if (z == lst) {
        dp[x][0] = geth(H, mn, mx, b - 1);
        dp[x][1] = geth(H, mn, mx, b + 1);
      } else {
        dp[x][0] = geth(H, mn, mx, b - 1, dp[z][0] - mn);
        dp[x][1] = geth(H, mn, mx, b - 1, dp[z][1] - mn);
      }
    } else {
      rt[x] = 0;
      if (~c[x]) return;
      for (const auto &y : g[x])
        if (y ^ f) {
          if (~c[y])
            b += c[y] ? 1 : -1;
          else
            H[dp[y][0] - mn] += 2, b--;
        }
      for (int i(H.size() - 2), _i(0); i >= _i; i--) H[i] += H[i + 1];
      dp[x][0] = geth(H, mn, mx, b);
    }
  }
}
int w[100010];
inline void dfs1(int x) {
  if (~c[x]) return w[x] = c[x], void();
  int b = ::b[x];
  for (const auto &o : e[x]) {
    int y, z;
    tie(y, z) = o;
    if (y ^ z)
      b += K <= dp[z][w[y]] ? 1 : -1;
    else
      b += w[y] ? 1 : -1;
  }
  b += H[x][max(min(K, mx[x] + 1), mn[x]) - mn[x]];
  w[x] = b >= K;
}
void work(int l, int r) {
  memset(mrk + 1, 0, n);
  *dfn = 0;
  for (int i(l), _i(r); i <= _i; i++) {
    const D &w = d[i];
    if (w.o ^ 3) mrk[w.x] = 1;
  }
  dfs0(1, 0);
  for (int i(l), _i(r); i <= _i; i++) {
    const D &w = d[i];
    if (w.o == 1) {
      for (int j(1), _j(*dfn); j <= _j; j++) dfs1(dfn[j]);
      printf("%d\n", ::w[w.x]);
    } else if (w.o == 2)
      c[w.x] = w.y;
    else
      K = w.x;
  }
}
void solve() {
  n = read(), K = read();
  for (int i(2), _i(n); i <= _i; i++) {
    int u = read(), v = read();
    g[u].emplace_back(v), g[v].emplace_back(u);
  }
  g[1].emplace_back(0);
  for (int i(1), _i(n); i <= _i; i++) c[i] = read();
  predfs(1, 0);
  q = read();
  for (int i(1), _i(q); i <= _i; i++) {
    D &w = d[i];
    w.o = read();
    w.x = read();
    if (w.o == 2) w.y = read();
  }
  for (int i = 1, j; i <= q; i = j + 1) {
    j = min(q, i + S - 1);
    work(i, j);
  }
}
int main() {
  for (int T = 1; T--;) solve();
  return 0;
}
