Problem: You are given a tree of n nodes. The tree is rooted at node 1, which is not considered as a leaf regardless of its degree.

Each leaf of the tree has one of the two colors: red or blue. Leaf node v initially has color s_{v}.

The color of each of the internal nodes (including the root) is determined as follows. 

  * Let b be the number of blue immediate children, and r be the number of red immediate children of a given vertex. 
  * Then the color of this vertex is blue if and only if b - r ≥ k, otherwise red. 



Integer k is a parameter that is same for all the nodes.

You need to handle the following types of queries: 

  * 1 v: print the color of node v; 
  * 2 v c: change the color of leaf v to c (c = 0 means red, c = 1 means blue); 
  * 3 h: update the current value of k to h. 

Input

The first line of the input consists of two integers n and k (2 ≤ n ≤ 10^{5}, -n ≤ k ≤ n) — the number of nodes and the initial parameter k.

Each of the next n - 1 lines contains two integers u and v (1 ≤ u,v ≤ n), denoting that there is an edge between vertices u and v.

The next line consists of n space separated integers — the initial array s (-1 ≤ s_i ≤ 1). s_{i} = 0 means that the color of node i is red. s_{i} = 1 means that the color of node i is blue. s_{i} = -1 means that the node i is not a leaf.

The next line contains an integer q (1 ≤ q ≤ 10^5), the number of queries.

q lines follow, each containing a query in one of the following queries: 

  * 1 v (1 ≤ v ≤ n): print the color of node v; 
  * 2 v c (1 ≤ v ≤ n, c = 0 or c = 1): change the color of leaf v to c (c = 0 means red, c = 1 means blue). It is guaranteed that v is a leaf; 
  * 3 h (-n ≤ h ≤ n): update the current value of k to h. 

Output

For each query of the first type, print 0 if the color of vertex v is red, and 1 otherwise.

Example

Input


5 2
1 2
1 3
2 4
2 5
-1 -1 0 1 0
9
1 1
1 2
3 -2
1 1
1 2
3 1
2 5 1
1 1
1 2


Output


0
0
1
1
0
1

Note

Figures:

(i) The initial tree 

(ii) The tree after the 3rd query 

(iii) The tree after the 7th query 

<image>

Solution (in CPP):

Solution:
#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;
}