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;
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
vector<int> adj[400010];
int nn, ns[400010], ne[400010];
int col[400010];
long long segtree[4 * 400010], lazy[4 * 400010];
int ulta[400010];
void dfs(int node, int par) {
  ns[node] = ++nn;
  ulta[nn] = node;
  for (auto b : adj[node]) {
    if (b == par) continue;
    dfs(b, node);
  }
  ne[node] = nn;
}
int beg, en;
void lazy_update(int lef, int rig, int cur, int val) {
  if (lazy[cur]) {
    segtree[cur] = lazy[cur];
    if (lef != rig) lazy[cur << 1] = lazy[(cur << 1) | 1] = lazy[cur];
    lazy[cur] = 0;
  }
  if (lef > en || rig < beg) return;
  if (lef >= beg && rig <= en) {
    segtree[cur] = (1ll << val);
    if (rig != lef) lazy[(cur << 1) | 1] = lazy[cur << 1] = (1ll << val);
    return;
  }
  int mid = (lef + rig) >> 1, b = (cur << 1);
  lazy_update(lef, mid, b, val);
  lazy_update(mid + 1, rig, b | 1, val);
  segtree[cur] = segtree[b] | segtree[b + 1];
}
long long query(int lef, int rig, int cur) {
  if (lazy[cur] > 0) {
    segtree[cur] = lazy[cur];
    if (lef != rig) lazy[cur << 1] = lazy[(cur << 1) | 1] = lazy[cur];
    lazy[cur] = 0;
  }
  if (lef > en || rig < beg) return 0ll;
  if (lef >= beg && rig <= en) return segtree[cur];
  int mid = (lef + rig) >> 1, b = (cur << 1);
  return query(lef, mid, b) | query(mid + 1, rig, b + 1);
}
void build(int lef, int rig, int cur) {
  if (lef == rig) {
    segtree[cur] = 1ll << col[ulta[lef]];
    return;
  }
  int mid = (lef + rig) >> 1, b = (cur << 1);
  build(lef, mid, b);
  build(mid + 1, rig, b | 1);
  segtree[cur] = segtree[b] | segtree[b + 1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int i, j, n, q, a, b, qt;
  cin >> n >> q;
  for (i = 1; i <= n; i++) cin >> col[i];
  for (i = 0; i < n - 1; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, -1);
  build(1, n, 1);
  while (q--) {
    cin >> qt;
    if (qt == 2) {
      cin >> a;
      beg = ns[a];
      en = ne[a];
      deb(__builtin_popcountll(query(1, n, 1)));
      continue;
    }
    cin >> a >> b;
    beg = ns[a];
    en = ne[a];
    lazy_update(1, n, 1, b);
  }
  return 0;
}