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 x = 0;
  bool flg = false;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') flg = true;
  for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
  return flg ? -x : x;
}
const int S = 750;
int n, K, q;
vector<int> g[100010];
vector<pair<int, int> > e[100010];
int c[100010];
struct D {
  int o, x, y;
} d[100010];
bool mrk[100010];
int rt[100010];
int dp[100010][2];
vector<int> H[100010];
int mn[100010], mx[100010];
int b[100010];
void predfs(int x, int f) {
  if (~c[x]) return;
  int L = 0;
  for (const auto &y : g[x])
    if (y ^ f) {
      predfs(y, x);
      L = max(L, int(g[y].size()) - 1);
    }
  mn[x] = -L, mx[x] = L;
  H[x].resize(L + 1 << 1);
}
inline int geth(const vector<int> &H, int mn, int mx, int w,
                const int p = -1e9) {
  int z = w;
  for (int i(H.size() - 1), _i(0); i >= _i; i--) {
    z = max(z, min(mn + i, w + H[i] + (int(i <= p) << 1)));
  }
  return z;
}
int dfn[100010];
void dfs0(int x, int f) {
  int tot = 0, lst = -1, z = -1;
  for (const auto &y : g[x])
    if (y ^ f) {
      dfs0(y, x);
      if (rt[y]) ++tot, lst = rt[y], z = y;
    }
  auto &H = ::H[x];
  fill((H).begin(), (H).end(), 0);
  const int &mn = ::mn[x], &mx = ::mx[x];
  int &b = ::b[x];
  b = 0;
  if (mrk[x] || tot >= 2) {
    dfn[++*dfn] = x;
    rt[x] = x;
    e[x].clear();
    for (const auto &y : g[x])
      if (y ^ f)
        if (rt[y]) e[x].emplace_back(rt[y], y);
    if (~c[x]) return;
    for (const auto &y : g[x])
      if (y ^ f && !rt[y]) {
        if (~c[y])
          b += c[y] ? 1 : -1;
        else
          H[dp[y][0] - mn] += 2, b--;
      }
    for (int i(H.size() - 2), _i(0); i >= _i; i--) H[i] += H[i + 1];
  } else {
    if (tot == 1) {
      rt[x] = lst;
      for (const auto &y : g[x])
        if (y ^ f && !rt[y]) {
          if (~c[y])
            b += c[y] ? 1 : -1;
          else
            H[dp[y][0] - mn] += 2, b--;
        }
      for (int i(H.size() - 2), _i(0); i >= _i; i--) H[i] += H[i + 1];
      if (z == lst) {
        dp[x][0] = geth(H, mn, mx, b - 1);
        dp[x][1] = geth(H, mn, mx, b + 1);
      } else {
        dp[x][0] = geth(H, mn, mx, b - 1, dp[z][0] - mn);
        dp[x][1] = geth(H, mn, mx, b - 1, dp[z][1] - mn);
      }
    } else {
      rt[x] = 0;
      if (~c[x]) return;
      for (const auto &y : g[x])
        if (y ^ f) {
          if (~c[y])
            b += c[y] ? 1 : -1;
          else
            H[dp[y][0] - mn] += 2, b--;
        }
      for (int i(H.size() - 2), _i(0); i >= _i; i--) H[i] += H[i + 1];
      dp[x][0] = geth(H, mn, mx, b);
    }
  }
}
int w[100010];
inline void dfs1(int x) {
  if (~c[x]) return w[x] = c[x], void();
  int b = ::b[x];
  for (const auto &o : e[x]) {
    int y, z;
    tie(y, z) = o;
    if (y ^ z)
      b += K <= dp[z][w[y]] ? 1 : -1;
    else
      b += w[y] ? 1 : -1;
  }
  b += H[x][max(min(K, mx[x] + 1), mn[x]) - mn[x]];
  w[x] = b >= K;
}
void work(int l, int r) {
  memset(mrk + 1, 0, n);
  *dfn = 0;
  for (int i(l), _i(r); i <= _i; i++) {
    const D &w = d[i];
    if (w.o ^ 3) mrk[w.x] = 1;
  }
  dfs0(1, 0);
  for (int i(l), _i(r); i <= _i; i++) {
    const D &w = d[i];
    if (w.o == 1) {
      for (int j(1), _j(*dfn); j <= _j; j++) dfs1(dfn[j]);
      printf("%d\n", ::w[w.x]);
    } else if (w.o == 2)
      c[w.x] = w.y;
    else
      K = w.x;
  }
}
void solve() {
  n = read(), K = read();
  for (int i(2), _i(n); i <= _i; i++) {
    int u = read(), v = read();
    g[u].emplace_back(v), g[v].emplace_back(u);
  }
  g[1].emplace_back(0);
  for (int i(1), _i(n); i <= _i; i++) c[i] = read();
  predfs(1, 0);
  q = read();
  for (int i(1), _i(q); i <= _i; i++) {
    D &w = d[i];
    w.o = read();
    w.x = read();
    if (w.o == 2) w.y = read();
  }
  for (int i = 1, j; i <= q; i = j + 1) {
    j = min(q, i + S - 1);
    work(i, j);
  }
}
int main() {
  for (int T = 1; T--;) solve();
  return 0;
}