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>
const int N = 100005, inf = 0x3f3f3f3f;
int n, k, head[N], tot;
int col[N];
struct edge {
  int to, nxt;
} e[N << 1];
void link(int x, int y) {
  e[++tot] = (edge){y, head[x]}, head[x] = tot;
  e[++tot] = (edge){x, head[y]}, head[y] = tot;
}
int size[N], f[N], son[N], top[N], bottom[N];
int dfn[N], idfn[N], deg[N], clk;
int dfs0(int x) {
  for (int i = head[x]; i; i = e[i].nxt)
    if (e[i].to != f[x]) {
      ++deg[x], f[e[i].to] = x, size[x] += dfs0(e[i].to);
      if (size[e[i].to] > size[son[x]]) son[x] = e[i].to;
    }
  return ++size[x];
}
void dfs1(int x) {
  dfn[x] = ++clk, idfn[clk] = x, bottom[x] = x;
  if (son[x]) top[son[x]] = top[x], dfs1(son[x]), bottom[x] = bottom[son[x]];
  for (int i = head[x]; i; i = e[i].nxt)
    if (e[i].to != son[x] && e[i].to != f[x])
      top[e[i].to] = e[i].to, dfs1(e[i].to);
}
std::mt19937 rnd(std::time(0) + (size_t) new char);
int root[N], lc[N], rc[N], val[N];
int idx, pri[N];
void pushup(int x) { size[x] = 1 + size[lc[x]] + size[rc[x]]; }
void split(int now, int k, int &x, int &y) {
  if (!now) return void(x = y = 0);
  if (val[now] <= k)
    x = now, split(rc[x], k, rc[x], y);
  else
    y = now, split(lc[y], k, x, lc[y]);
  pushup(now);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  if (pri[x] < pri[y])
    return rc[x] = merge(rc[x], y), pushup(x), x;
  else
    return lc[y] = merge(x, lc[y]), pushup(y), y;
}
int build(int n) {
  if (n == 1) return pri[++idx] = rnd(), pushup(idx), idx;
  return merge(build(n >> 1), build(n + 1 >> 1));
}
void replace(int &rt, int x, int y) {
  int a, b;
  split(rt, x, rt, b), split(rt, x - 1, a, rt);
  a = merge(merge(a, lc[rt]), merge(rc[rt], b));
  lc[rt] = rc[rt] = 0, pushup(rt), split(a, y, a, b);
  pri[rt] = rnd(), val[rt] = y, rt = merge(merge(a, rt), b);
}
int rank(int &rt, int x) {
  int a, ret;
  split(rt, x, a, rt), ret = size[a];
  return rt = merge(a, rt), ret;
}
std::pair<int, int> operator+(std::pair<int, int> a, std::pair<int, int> b) {
  return std::pair<int, int>(std::min(std::max(b.first, a.second), a.first),
                             std::min(std::max(b.second, a.second), a.first));
}
const std::pair<int, int> init[3] = {{-inf, -inf}, {inf, inf}, {inf, -inf}};
bool check(int x, int k, int delta) {
  int r = rank(root[x], k), b = deg[x] - r - 1;
  return k >= b - r + delta + 1;
}
void maintain(int x, int &k, int delta) {
  while (check(x, k - 1, delta)) --k;
  while (!check(x, k, delta)) ++k;
}
void update(int x, std::pair<int, int> &p) {
  if (col[x] == -1) {
    maintain(x, p.first, 1);
    maintain(x, p.second, -1);
  } else
    p = init[col[x]];
}
std::pair<int, int> sum[N << 2];
void s_pushup(int o) { sum[o] = sum[o << 1] + sum[o << 1 | 1]; }
std::pair<int, int> query(int L, int R, int o = 1, int l = 1, int r = n) {
  if (L <= l && r <= R) return sum[o];
  int mid = l + r >> 1;
  std::pair<int, int> ret = init[2];
  if (L <= mid) ret = ret + query(L, R, o << 1, l, mid);
  if (R > mid) ret = ret + query(L, R, o << 1 | 1, mid + 1, r);
  return ret;
}
std::vector<int> light[N];
int answer(int x) { return query(dfn[x], dfn[bottom[x]]).first; }
void s_build(int pos, int o = 1, int l = 1, int r = n) {
  if (l == r) {
    int u = idfn[l];
    for (int p : light[u]) replace(root[u], 0, answer(p));
    return update(u, sum[o]);
  }
  int mid = l + r >> 1;
  if (pos <= mid)
    s_build(pos, o << 1, l, mid);
  else
    s_build(pos, o << 1 | 1, mid + 1, r);
  s_pushup(o);
}
void modify(int pos, int o = 1, int l = 1, int r = n) {
  if (l == r) return update(idfn[l], sum[o]);
  int mid = l + r >> 1;
  if (pos <= mid)
    modify(pos, o << 1, l, mid);
  else
    modify(pos, o << 1 | 1, mid + 1, r);
  s_pushup(o);
}
void maintain(int x) {
  for (; x; x = f[x]) {
    int p = answer(top[x]);
    modify(dfn[x]), x = top[x];
    if (f[x]) replace(root[f[x]], p, answer(x));
  }
}
void debug(int x) { std::cout << "debug : " << x << '\n'; }
void debug_dfs(int x) {
  if (!x) return;
  debug_dfs(lc[x]);
  std::cout << val[x] << ' ';
  debug_dfs(rc[x]);
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> k;
  for (int i = 1, x, y; i < n; ++i) std::cin >> x >> y, link(x, y);
  dfs0(1), top[1] = 1, dfs1(1);
  std::memset(size, 0, sizeof size);
  for (int i = 1; i <= n; ++i) std::cin >> col[i];
  for (int i = 1; i <= n; ++i)
    if (deg[i] > 1) root[i] = build(deg[i] - 1);
  for (int i = 2; i <= n; ++i)
    if (i == top[i]) light[f[i]].emplace_back(i);
  for (int i = n; i; --i) s_build(i);
  int q;
  std::cin >> q;
  while (q--) {
    int opt, v, c;
    std::cin >> opt >> v;
    if (opt == 1)
      std::cout << (k < answer(v)) << '\n';
    else if (opt == 2)
      std::cin >> c, col[v] = c, maintain(v);
    else
      k = v;
  }
  return 0;
}