Problem: The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree.

The New Year tree is an undirected tree with n vertices and root in the vertex 1.

You should process the queries of the two types:

  1. Change the colours of all vertices in the subtree of the vertex v to the colour c. 
  2. Find the number of different colours in the subtree of the vertex v. 

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 4·105) — the number of vertices in the tree and the number of the queries.

The second line contains n integers ci (1 ≤ ci ≤ 60) — the colour of the i-th vertex.

Each of the next n - 1 lines contains two integers xj, yj (1 ≤ xj, yj ≤ n) — the vertices of the j-th edge. It is guaranteed that you are given correct undirected tree.

The last m lines contains the description of the queries. Each description starts with the integer tk (1 ≤ tk ≤ 2) — the type of the k-th query. For the queries of the first type then follows two integers vk, ck (1 ≤ vk ≤ n, 1 ≤ ck ≤ 60) — the number of the vertex whose subtree will be recoloured with the colour ck. For the queries of the second type then follows integer vk (1 ≤ vk ≤ n) — the number of the vertex for which subtree you should find the number of different colours.

Output

For each query of the second type print the integer a — the number of different colours in the subtree of the vertex given in the query.

Each of the numbers should be printed on a separate line in order of query appearing in the input.

Examples

Input

7 10
1 1 1 1 1 1 1
1 2
1 3
1 4
3 5
3 6
3 7
1 3 2
2 1
1 4 3
2 1
1 2 5
2 1
1 6 4
2 1
2 2
2 3


Output

2
3
4
5
1
2


Input

23 30
1 2 2 6 5 3 2 1 1 1 2 4 5 3 4 4 3 3 3 3 3 4 6
1 2
1 3
1 4
2 5
2 6
3 7
3 8
4 9
4 10
4 11
6 12
6 13
7 14
7 15
7 16
8 17
8 18
10 19
10 20
10 21
11 22
11 23
2 1
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 4
1 12 1
1 13 1
1 14 1
1 15 1
1 16 1
1 17 1
1 18 1
1 19 1
1 20 1
1 21 1
1 22 1
1 23 1
2 1
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 4


Output

6
1
3
3
2
1
2
3
5
5
1
2
2
1
1
1
2
3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
class tree {
  int ct;

 public:
  int nn, root;
  vector<int> parent;
  vector<int> depth;
  vector<int> sz;
  vector<vector<int>> adj;
  vector<vector<int>> sons;
  vector<int> in, out;
  vector<int> pos;
  vector<vector<int>> pred;
  int MAXLEVEL;
  tree(int n) {
    nn = n;
    parent.assign(n, -1);
    adj.clear();
    adj.resize(n);
    depth.assign(n, -1);
    sz.assign(n, 0);
    sons.clear();
    sons.resize(n);
  }
  void add_path(int a, int b) {
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  void add_directed_path(int a, int b) { adj[a].push_back(b); }
  void dfs_set_root(int id, bool cartesian_decomposition = false) {
    if (cartesian_decomposition) {
      in[id] = ct;
      pos[ct] = id;
      ct++;
    }
    sz[id]++;
    for (auto p : adj[id]) {
      if (parent[p] == -1) {
        parent[p] = id;
        depth[p] = depth[id] + 1;
        dfs_set_root(p, cartesian_decomposition);
        sz[id] += sz[p];
        sons[id].push_back(p);
      }
    }
    if (cartesian_decomposition) out[id] = ct - 1;
  }
  void set_root(int id, bool cartesian_decomposition = false) {
    if (cartesian_decomposition) {
      in.resize(nn);
      out.resize(nn);
      pos.resize(nn);
      ct = 0;
    }
    parent[id] = 0;
    depth[id] = 0;
    dfs_set_root(id, cartesian_decomposition);
  }
  void prep_LCA() {
    MAXLEVEL = 1;
    while ((1 << MAXLEVEL) < nn) MAXLEVEL++;
    MAXLEVEL++;
    pred.assign(MAXLEVEL, vector<int>(nn, 0));
    pred[0] = parent;
    int i, j, k;
    for (i = 1; i < MAXLEVEL; i++) {
      for (j = 0; j < nn; j++) {
        if (pred[i - 1][j] != -1) pred[i][j] = pred[i - 1][pred[i - 1][j]];
      }
    }
  }
  int LCA(int a, int b) {
    int da = depth[a], db = depth[b];
    if (da > db) {
      swap(da, db);
      swap(a, b);
    }
    int i, j, k;
    for (i = MAXLEVEL - 1; i >= 0; i--) {
      if (db - (1 << i) >= da) {
        db -= (1 << i);
        b = pred[i][b];
      }
    }
    if (a == b) return a;
    for (i = MAXLEVEL - 1; i >= 0; i--) {
      if (pred[i][a] != pred[i][b]) {
        a = pred[i][a];
        b = pred[i][b];
      }
    }
    return parent[a];
  }
  int get_distance(int a, int b) {
    int c = LCA(a, b);
    int ans = depth[a] + depth[b] - 2 * depth[c];
    return ans;
  }
};
struct lst_node {
  long long val;
  long long offset;
  bool current;
};
class lazy_segment_tree {
 public:
  long long size;
  vector<lst_node> node_list;
  lazy_segment_tree() {}
  void initialize_empty(long long n) {
    size = n;
    lst_node lsd;
    lsd.val = 0;
    lsd.offset = 0;
    lsd.current = true;
    node_list.assign(size * 4 + 100, lsd);
  }
  long long build_tree(long long l, long long r, long long p,
                       vector<long long>& a) {
    if (l == r) {
      node_list[p].val = a[l];
      node_list[p].offset = a[l];
      node_list[p].current = true;
      return p;
    } else {
      long long m = (l + r) >> 1;
      build_tree(l, m, p * 2, a);
      build_tree(m + 1, r, p * 2 + 1, a);
      node_list[p].val = node_list[p * 2].val | node_list[p * 2 + 1].val;
      node_list[p].offset = 0;
      node_list[p].current = false;
      return p;
    }
  }
  void initialize(vector<long long>& a) {
    size = a.size();
    node_list.assign(size * 4 + 100, {0, 0});
    build_tree(0, size - 1, 1, a);
  }
  long long update(long long pos, long long key) {
    long long ans = update_range_full(1, 0, size - 1, pos, pos, key);
    return ans;
  }
  long long update_range(long long l, long long r, long long off) {
    long long ans = update_range_full(1, 0, size - 1, l, r, off);
    return ans;
  }
  long long update_range_full(long long p, long long left, long long right,
                              long long l, long long r, long long off) {
    if (left > right) return p;
    if ((left >= l) && (right <= r)) {
      if (left == right) {
        node_list[p].val = off;
        node_list[p].current = true;
        node_list[p].offset = off;
      } else {
        node_list[p].offset = off;
        node_list[p].current = true;
        node_list[p].val = off;
      }
      return p;
    } else {
      long long m = (left + right) >> 1;
      long long a, b;
      if (node_list[p].current) {
        a = update_range_full(p * 2, left, m, left, m, node_list[p].offset);
        a = update_range_full(p * 2 + 1, m + 1, right, m + 1, right,
                              node_list[p].offset);
      }
      if (m >= l) {
        a = update_range_full(p * 2, left, m, l, r, off);
      }
      if (m + 1 <= r) {
        b = update_range_full(p * 2 + 1, m + 1, right, l, r, off);
      }
      a = p * 2;
      b = p * 2 + 1;
      node_list[p].val = node_list[a].val | node_list[b].val;
      node_list[p].current = false;
      return p;
    }
  }
  long long query(long long l, long long r) {
    if (l > r) {
      return 0;
    }
    return query_full(1, 0, size - 1, l, r);
  }
  inline long long query_full(long long p, long long left, long long right,
                              long long l, long long r) {
    if (right < left) return 0;
    if ((left >= l) && (right <= r)) return node_list[p].val;
    if (node_list[p].current) return node_list[p].offset;
    long long m = (left + right) >> 1, ans = 0;
    if (m >= l) {
      ans |= query_full(p * 2, left, m, l, r);
    }
    if (m + 1 <= r) {
      ans |= query_full(p * 2 + 1, m + 1, right, l, r);
    }
    return ans;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, i, j, k, a, b, ans, id, sq, q, x, cc;
  cin >> n >> m;
  vector<long long> c(n + 1), cv;
  c[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> x;
    c[i] = 1LL << x;
  }
  tree tr(n + 1);
  for (i = 0; i < n - 1; i++) {
    cin >> a >> b;
    tr.add_path(a, b);
  }
  tr.set_root(1, true);
  tr.prep_LCA();
  cv.resize(n);
  for (i = 0; i < n; i++) {
    cv[i] = c[tr.pos[i]];
  }
  lazy_segment_tree lst;
  lst.initialize(cv);
  while (m--) {
    cin >> id;
    if (id == 1) {
      cin >> x >> cc;
      cc = 1LL << cc;
      lst.update_range(tr.in[x], tr.out[x], cc);
    } else {
      cin >> x;
      long long v = lst.query(tr.in[x], tr.out[x]);
      ans = 0;
      for (i = 0; i < 62; i++) {
        if ((1LL << i) & v) ans++;
      }
      cout << ans << "\n";
    }
  }
  return 0;
}