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 RLEN = 1 << 20 | 1;
inline char gc() {
  static char ibuf[RLEN], *ib, *ob;
  (ob == ib) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
  return (ob == ib) ? EOF : *ib++;
}
inline int read() {
  char ch = getchar();
  int res = 0, f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = getchar();
  return f ? res : -res;
}
template <class tp>
inline void chemx(tp &a, tp b) {
  a < b ? a = b : 0;
}
template <class tp>
inline void chemn(tp &a, tp b) {
  a > b ? a = b : 0;
}
const int N = 100005;
inline int rnd() { return (rand() << 15) | rand(); }
int rt[N];
namespace treap {
int key[N], val[N], lc[N], rc[N], siz[N], tot, stk[N], top;
inline void pushup(int u) { siz[u] = siz[lc[u]] + siz[rc[u]] + 1; }
inline int newnode(int v) {
  int u = top ? stk[top--] : (++tot);
  lc[u] = rc[u] = 0, val[u] = v, key[u] = rnd(), siz[u] = 1;
  return u;
}
inline void split(int u, int &r1, int &r2, int k) {
  if (!u) {
    r1 = r2 = 0;
    return;
  }
  if (k <= siz[lc[u]])
    r2 = u, split(lc[u], r1, lc[r2], k);
  else
    r1 = u, split(rc[u], rc[r1], r2, k - siz[lc[u]] - 1);
  pushup(u);
}
inline void merge(int &u, int r1, int r2) {
  if (!r1 || !r2) {
    u = r1 + r2;
    return;
  }
  if (key[r1] < key[r2])
    u = r1, merge(rc[u], rc[r1], r2);
  else
    u = r2, merge(lc[u], r1, lc[r2]);
  pushup(u);
}
inline int getrk(int u, int k) {
  if (!u) return 0;
  if (val[u] > k)
    return getrk(lc[u], k);
  else
    return siz[lc[u]] + 1 + getrk(rc[u], k);
}
inline void insert(int &u, int k) {
  int r1 = 0, r2 = 0, now = newnode(k);
  int rk = getrk(u, k);
  split(u, r1, r2, rk);
  merge(r1, r1, now);
  merge(u, r1, r2);
}
inline void delet(int &u, int k) {
  int r1 = 0, r2 = 0, r3 = 0;
  int rk = getrk(u, k);
  split(u, r1, r2, rk - 1);
  split(r2, r2, r3, 1);
  stk[++top] = r2;
  merge(u, r1, r3);
}
}  // namespace treap
struct fuc {
  int p0, p1;
  fuc(int _0 = 0, int _1 = 0) : p0(_0), p1(_1) {}
  friend inline fuc operator*(const fuc &a, const fuc &b) {
    return fuc(min(max(a.p0, b.p0), a.p1), min(max(a.p0, b.p1), a.p1));
  }
};
int n, m;
vector<int> e[N];
int col[N], top[N], siz[N], son[N], dep[N], fa[N], but[N], in[N], out[N],
    idx[N], dfn;
namespace Seg {
fuc f[N << 2];
inline void pushup(int u) { f[u] = f[(u << 1)] * f[((u << 1) | 1)]; }
fuc query(int u, int l, int r, int st, int des) {
  if (st <= l && r <= des) return f[u];
  if (des <= ((l + r) >> 1)) return query((u << 1), l, ((l + r) >> 1), st, des);
  if (((l + r) >> 1) < st)
    return query(((u << 1) | 1), ((l + r) >> 1) + 1, r, st, des);
  return query((u << 1), l, ((l + r) >> 1), st, des) *
         query(((u << 1) | 1), ((l + r) >> 1) + 1, r, st, des);
}
inline void updatefa(int u, fuc now) {
  if (u == top[u] && fa[u]) {
    if (!son[u])
      treap::insert(rt[fa[u]], now.p0);
    else
      treap::insert(rt[fa[u]],
                    (now * query(1, 1, n, in[u] + 1, in[but[u]])).p0);
  }
}
inline bool check(int u, int t, int del) {
  int cr = treap::getrk(rt[u], t) + del, cb = treap::siz[rt[u]] - cr + 1;
  return cb - cr < t;
}
inline int get(int k, int mor, int u) {
  while (check(u, k - 1, mor)) k--;
  while (!check(u, k, mor)) k++;
  return k;
}
void getval(int u, int node) {
  if (col[node] == 0) f[u] = fuc(-1e9, -1e9);
  if (col[node] == 1) f[u] = fuc(1e9, 1e9);
  if (col[node] == -1) {
    f[u].p0 = get(f[u].p0, 1, node);
    f[u].p1 = get(f[u].p1, 0, node);
  }
}
void build(int u, int l, int r) {
  if (l == r) {
    getval(u, idx[l]);
    updatefa(idx[l], f[u]);
    return;
  }
  build(((u << 1) | 1), ((l + r) >> 1) + 1, r),
      build((u << 1), l, ((l + r) >> 1));
  pushup(u);
}
void update(int u, int l, int r, int p) {
  if (l == r) {
    getval(u, idx[l]);
    return;
  }
  if (p <= ((l + r) >> 1))
    update((u << 1), l, ((l + r) >> 1), p);
  else
    update(((u << 1) | 1), ((l + r) >> 1) + 1, r, p);
  pushup(u);
}
}  // namespace Seg
void dfs1(int u) {
  siz[u] = 1;
  for (int &v : e[u]) {
    if (v == fa[u]) continue;
    dep[v] = dep[u] + 1, fa[v] = u;
    dfs1(v), siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp, in[u] = ++dfn, idx[dfn] = u;
  but[tp] = u;
  if (son[u]) dfs2(son[u], tp);
  for (int &v : e[u]) {
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
  out[u] = dfn;
}
inline void update(int u) {
  while (u) {
    if (fa[top[u]])
      treap::delet(rt[fa[top[u]]],
                   Seg::query(1, 1, n, in[top[u]], in[but[top[u]]]).p0);
    Seg::update(1, 1, n, in[u]);
    if (fa[top[u]])
      treap::insert(rt[fa[top[u]]],
                    Seg::query(1, 1, n, in[top[u]], in[but[top[u]]]).p0);
    u = fa[top[u]];
  }
}
int K;
int main() {
  n = read(), K = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    e[u].push_back(v), e[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) col[i] = read();
  dfs1(1), dfs2(1, 1);
  Seg::build(1, 1, n);
  m = read();
  for (int i = 1; i <= m; i++) {
    int op = read();
    if (op == 1) {
      int u = read();
      cout << (Seg::query(1, 1, n, in[u], in[but[top[u]]]).p0 > K) << '\n';
    } else if (op == 2) {
      int u = read(), c = read();
      col[u] = c, update(u);
    } else {
      K = read();
    }
  }
}