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;
inline int read() {
  char c = getchar();
  int out = 0, f = 1;
  while (!(c >= '0' && c <= '9')) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    out = out * 10 + c - '0';
    c = getchar();
  }
  return out * f;
}
int n, k;
class Query {
 public:
  int p, k, t;
};
int tim, dfn[100010], fa[100010][17], dep[100010], c[100010], up[100010],
    vt[100010], vte[100010], val[100010][2];
char cl[1506][100002];
vector<Query> q;
vector<int> v[100010], s, v1[100010], vals[100010];
void dfs(int p, int fath) {
  dfn[p] = ++tim;
  fa[p][0] = fath;
  for (int i = 1; i <= 16; i++) fa[p][i] = fa[fa[p][i - 1]][i - 1];
  dep[p] = dep[fath] + 1;
  for (int x : v[p]) {
    if (x != fath) dfs(x, p);
  }
}
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 16; i >= 0; i--) {
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  }
  if (x == y) return x;
  for (int i = 16; i >= 0; i--) {
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  }
  return fa[x][0];
}
void calc(vector<int> &s, int &v) {
  sort(s.begin(), s.end());
  int l = -n - 10, r = n + 10;
  while (l < r) {
    int mid = (l + r) >> 1;
    int cntb = 0, cntr = 0;
    for (int x : s)
      if (x < mid)
        cntr++;
      else
        cntb++;
    if (cntb - cntr >= mid)
      l = mid + 1;
    else
      r = mid;
  }
  v = l - 1;
}
void dfs1(int p) {
  if (vt[p]) val[p][0] = -1e9, val[p][1] = 1e9;
  if (c[p] != -1) {
    if (!vt[p]) val[p][0] = val[p][1] = c[p] ? 1e9 : -1e9;
    return;
  }
  vector<int> s0, s1;
  for (int x : v[p]) {
    if (x != fa[p][0]) {
      dfs1(x);
      if (!vte[x]) vals[p].push_back(val[x][0]);
      s0.push_back(val[x][0]);
      s1.push_back(val[x][1]);
    }
  }
  if (vt[p]) return;
  calc(s0, val[p][0]);
  calc(s1, val[p][1]);
  sort(vals[p].begin(), vals[p].end());
}
int query(int p, int k, int t) {
  if (c[p] != -1) return cl[t][p];
  int cb = 0, cr = 0;
  for (int x : v1[p]) {
    if (val[up[x]][query(x, k, t)] >= k)
      cb++;
    else
      cr++;
  }
  int r = lower_bound(vals[p].begin(), vals[p].end(), k) - vals[p].begin(),
      b = vals[p].size() - r;
  return b + cb - r - cr >= k;
}
inline int comp(int a, int b) { return dfn[a] < dfn[b]; }
int Q, stk[200010];
int main() {
  n = read();
  k = read();
  for (int i = 1, ti, tj; i < n; i++) {
    ti = read();
    tj = read();
    v[ti].push_back(tj);
    v[tj].push_back(ti);
  }
  for (int i = 1; i <= n; i++) c[i] = read();
  dfs(1, 0);
  Q = read();
  for (int i = 1; i <= Q; i += 1500) {
    for (int j = 1; j <= n; j++) cl[0][j] = c[j];
    q.clear();
    s.clear();
    for (int j = 1, opt, x, y; j <= min(1500, Q - i + 1); j++) {
      opt = read();
      x = read();
      memcpy(cl[j], cl[j - 1], sizeof(cl[j]));
      if (opt == 1)
        q.push_back((Query){x, k, j}), s.push_back(x);
      else if (opt == 2) {
        y = read();
        cl[j][x] = y;
        c[x] = y;
        s.push_back(x);
      } else
        k = x;
    }
    if (!s.size()) continue;
    sort(s.begin(), s.end(), comp);
    s.erase(unique(s.begin(), s.end()), s.end());
    for (int j = 1; j <= n; j++) v1[j].clear(), vals[j].clear();
    memset(vt, 0, sizeof(vt));
    memset(vte, 0, sizeof(vte));
    int tp = 1;
    stk[1] = s[0];
    vt[s[0]] = 1;
    for (int x : s) {
      if (x == s[0]) continue;
      int p = lca(x, stk[tp]);
      while (tp > 1 && dep[stk[tp - 1]] >= dep[p])
        v1[stk[tp - 1]].push_back(stk[tp]), tp--;
      if (stk[tp] != p) v1[p].push_back(stk[tp]), stk[tp] = p, vt[p] = 1;
      stk[++tp] = x;
      vt[x] = 1;
    }
    while (tp > 1) v1[stk[tp - 1]].push_back(stk[tp]), tp--;
    for (int x : s) {
      for (; x && !vte[x]; x = fa[x][0]) vte[x] = 1;
    }
    for (int j = 1; j <= n; j++) {
      if (vt[j]) {
        for (up[j] = j; up[j] && !vt[fa[up[j]][0]]; up[j] = fa[up[j]][0])
          ;
      }
    }
    dfs1(1);
    for (auto &x : q) printf("%d\n", query(x.p, x.k, x.t));
  }
  return 0;
}