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;
int read() {
  int a = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) {
    f = c == '-';
    c = getchar();
  }
  while (isdigit(c)) {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return f ? -a : a;
}
const int _ = 4e5 + 7;
int N, K, Q, sz[_], fa[_], ans[_], col[_];
vector<int> nxt[_];
void dfs(int x, int p) {
  sz[x] = 1;
  fa[x] = p;
  for (auto t : nxt[x])
    if (t != p) {
      dfs(t, x);
      sz[x] += sz[t];
    }
}
int op[_][3];
int sum[_];
bool vislim[_];
vector<pair<int, int> > qry[_];
void calc_change() {
  priority_queue<pair<int, int> > q;
  for (int i = 1; i <= N; ++i)
    if (col[i] == -1) col[i] = 1;
  for (int i = 1; i <= N; ++i)
    for (auto t : nxt[i])
      if (t != fa[i]) sum[i] += 2 * col[t] - 1;
  for (int i = 1; i <= N; ++i)
    if (nxt[i].size() - !!fa[i]) q.push(make_pair(-sum[i] - 1, i));
  for (int i = -N; i <= N; ++i) {
    while (!q.empty() && -q.top().first <= i) {
      int t = q.top().second;
      q.pop();
      if (vislim[t]) continue;
      col[t] = 0;
      vislim[t] = 1;
      if (!vislim[fa[t]] && fa[t])
        q.push(make_pair(-(sum[fa[t]] -= 2) - 1, fa[t]));
    }
    for (auto t : qry[i + N]) ans[t.second] = 2 * col[t.first] - 1;
  }
}
namespace bf {
int calc(int x) {
  if (col[x] != -1) return col[x];
  int sum = 0;
  for (int i = 0; i < nxt[x].size() && !(sum + (int)nxt[x].size() - i < K ||
                                         sum - (int)nxt[x].size() + i >= K);
       ++i)
    if (nxt[x][i] != fa[x]) sum += 2 * calc(nxt[x][i]) - 1;
  return sum >= K;
}
void work() {
  for (int i = 1; i <= N; ++i)
    sort(nxt[i].begin(), nxt[i].end(),
         [&](int p, int q) { return sz[p] < sz[q]; });
  for (int i = 1; i <= Q; ++i) {
    int tp = op[i][0], x = op[i][1];
    switch (tp) {
      case 1:
        cout << calc(x) << '\n';
        break;
      case 2:
        col[x] = op[i][2];
        break;
      case 3:
        K = x;
        break;
    }
  }
}
}  // namespace bf
int main() {
  N = read();
  K = read();
  for (int i = 1; i < N; ++i) {
    int u = read(), v = read();
    nxt[u].push_back(v);
    nxt[v].push_back(u);
  }
  for (int i = 1; i <= N; ++i) {
    col[i] = read();
  }
  dfs(1, 0);
  bool flg = 1;
  Q = read();
  for (int i = 1; i <= Q; ++i) {
    op[i][0] = read();
    op[i][1] = read();
    if (op[i][0] == 2) {
      op[i][2] = read();
      flg = 0;
    }
  }
  if (flg) {
    for (int i = 1; i <= Q; ++i) {
      int tp = op[i][0], x = op[i][1];
      if (tp == 3)
        K = x;
      else
        qry[K + N].push_back(pair<int, int>(x, i));
    }
    calc_change();
    for (int i = 1; i <= Q; ++i)
      if (ans[i]) printf("%d\n", (ans[i] + 1) / 2);
  } else
    bf::work();
  return 0;
}