#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, k, he[maxn], ne[maxn << 1], to[maxn << 1], tot, fa[maxn], col[maxn];
int sz[maxn], hson[maxn], top[maxn], bot[maxn], id[maxn];
int rt[maxn];
struct node {
  int lc, rc, pri, sz, val;
} p[maxn];
struct data {
  int l, r;
  data(int l = 0, int r = 0) : l(l), r(r) {}
  inline const data operator*(const data &p) const {
    return data(min(r, max(l, p.l)), max(l, min(r, p.r)));
  }
} tr[maxn << 2], cur[maxn];
inline int newnode(int x) {
  p[tot].lc = p[tot].rc = 0, p[tot].pri = rand(), p[tot].sz = 1, p[tot].val = x;
  return tot++;
}
inline void pushup_treap(int rt) {
  p[rt].sz = 1 + p[p[rt].lc].sz + p[p[rt].rc].sz;
}
void merge(int &rt, int l, int r) {
  if ((!l) || (!r)) {
    rt = l | r;
    return;
  }
  if (p[l].pri < p[r].pri)
    rt = l, merge(p[rt].rc, p[l].rc, r);
  else
    rt = r, merge(p[rt].lc, l, p[r].lc);
  pushup_treap(rt);
}
void split(int rt, int &l, int &r, int x) {
  if (!rt) {
    l = r = 0;
    return;
  }
  if (p[rt].val <= x)
    l = rt, split(p[rt].rc, p[l].rc, r, x), pushup_treap(l);
  else
    r = rt, split(p[rt].lc, l, p[r].lc, x), pushup_treap(r);
}
inline int query(int rt, int B) {
  int tot = p[rt].sz + 1, res = 2 * B - tot;
  while (rt) {
    res = max(res, min(p[rt].val, 2 * (1 + B + p[p[rt].rc].sz) - tot));
    if (p[rt].val > 2 * (1 + B + p[p[rt].rc].sz) - tot)
      B += 1 + p[p[rt].rc].sz, rt = p[rt].lc;
    else
      rt = p[rt].rc;
  }
  return res;
}
inline void pushup_seg(int rt) { tr[rt] = tr[rt << 1] * tr[(rt << 1) | 1]; }
void build(int rt, int l, int r) {
  if (l == r) {
    tr[rt] = cur[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid), build((rt << 1) | 1, mid + 1, r);
  pushup_seg(rt);
}
void update(int rt, int l, int r, int x) {
  if (l == r) {
    tr[rt] = cur[l];
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(rt << 1, l, mid, x);
  else
    update((rt << 1) | 1, mid + 1, r, x);
  pushup_seg(rt);
}
data query(int rt, int l, int r, int x, int y) {
  if (x <= l && r <= y) return tr[rt];
  int mid = (l + r) >> 1;
  if (y <= mid) return query(rt << 1, l, mid, x, y);
  if (mid < x) return query((rt << 1) | 1, mid + 1, r, x, y);
  return query(rt << 1, l, mid, x, y) * query((rt << 1) | 1, mid + 1, r, x, y);
}
inline void add_edge(int u, int v) {
  to[tot] = v, ne[tot] = he[u], he[u] = tot++;
}
void dfs1(int u) {
  int i;
  sz[u] = 1, hson[u] = 0;
  for (i = he[u]; ~i; i = ne[i])
    if (to[i] != fa[u]) {
      fa[to[i]] = u;
      dfs1(to[i]);
      sz[u] += sz[to[i]];
      if (sz[to[i]] >= sz[hson[u]]) hson[u] = to[i];
    }
}
void dfs2(int u, int t) {
  tot++, id[u] = tot, top[u] = t;
  if (!hson[u]) {
    bot[u] = u;
    return;
  }
  int i;
  dfs2(hson[u], t), bot[u] = bot[hson[u]];
  for (i = he[u]; ~i; i = ne[i])
    if (to[i] != fa[u] && to[i] != hson[u]) dfs2(to[i], to[i]);
}
void init(int u) {
  if (sz[u] == 1) {
    cur[id[u]].l = cur[id[u]].r = col[u];
    return;
  }
  int i, a, b;
  rt[u] = 0;
  for (i = he[u]; ~i; i = ne[i])
    if (to[i] != fa[u] && to[i] != hson[u]) {
      init(to[i]);
      split(rt[u], a, b, col[to[i]]);
      merge(b, newnode(col[to[i]]), b);
      merge(rt[u], a, b);
    }
  cur[id[u]] = data(query(rt[u], 0), query(rt[u], 1));
  init(hson[u]);
  col[u] = max(cur[id[u]].l, min(cur[id[u]].r, col[hson[u]]));
}
int main() {
  int i, u, v, q, a, b, c;
  scanf("%d%d", &n, &k);
  for (tot = 0, i = 1; i <= n; i++) he[i] = -1;
  for (i = 1; i < n; i++) scanf("%d%d", &u, &v), add_edge(u, v), add_edge(v, u);
  sz[0] = 0, fa[1] = 0, dfs1(1), tot = 0, dfs2(1, 1);
  for (i = 1; i <= n; i++) {
    scanf("%d", &col[i]);
    if (col[i] != -1) col[i] = col[i] ? n + 1 : -(n + 1);
  }
  p[0].sz = 0, p[0].lc = p[0].rc = 0, tot = 1, init(1);
  build(1, 1, n);
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &i);
    if (i == 3)
      scanf("%d", &k);
    else if (i == 1)
      scanf("%d", &u),
          printf("%d\n", (query(1, 1, n, id[u], id[bot[u]]).l >= k) ? 1 : 0);
    else {
      scanf("%d%d", &u, &i), cur[id[u]].l = cur[id[u]].r = i ? n + 1 : -(n + 1);
      for (update(1, 1, n, id[u]), u = top[u]; fa[u]; u = top[fa[u]]) {
        split(rt[fa[u]], rt[fa[u]], a, col[u] - 1);
        split(a, a, b, col[u]);
        assert(a);
        c = a, merge(a, p[a].lc, p[a].rc);
        merge(a, a, b);
        merge(rt[fa[u]], rt[fa[u]], a);
        col[u] = query(1, 1, n, id[u], id[bot[u]]).l;
        p[c].lc = p[c].rc = 0, p[c].sz = 1, p[c].val = col[u];
        split(rt[fa[u]], a, b, col[u]);
        merge(b, c, b);
        merge(rt[fa[u]], a, b);
        cur[id[fa[u]]] = data(query(rt[fa[u]], 0), query(rt[fa[u]], 1));
        update(1, 1, n, id[fa[u]]);
      }
    }
  }
  return 0;
}
