#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 100;
const long long MaxN = 1e5 + 100;
const long long mod = 1e9 + 7;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
inline long long fast_expo(long long base, long long power,
                           long long modulo = mod) {
  long long x = base, cnt = power, ans = 1;
  while (cnt) {
    if (cnt & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    cnt >>= 1;
  }
  long long tmp = ans;
  return tmp;
}
inline long long fib(long long n, long long a = 1, long long b = 1,
                     long long c = 1, long long d = 0, long long acca = 0,
                     long long accb = 1, long long m = mod) {
  if (n == 0) return acca;
  if (n & 1)
    return fib(n / 2, ((a * a) % m + (b * c) % m) % m,
               ((a * b) % m + (b * d) % m) % m, (c * (a + d) % m) % m,
               ((c * b) % m + (d * d) % m) % m,
               ((a * acca) % m + (b * accb) % m) % m,
               ((c * acca) % m + (d * accb) % m) % m, m);
  else
    return fib(n / 2, ((a * a) % m + (b * c) % m) % m,
               ((a * b) % m + (b * d) % m) % m, (c * (a + d) % m) % m,
               ((c * b) % m + (d * d) % m) % m, acca, accb, m);
}
struct base {
  double x, y;
  base() {
    x = 0;
    y = 0;
  }
  base(double a) {
    x = a;
    y = 0;
  }
  base(double a, double b) {
    x = a;
    y = b;
  }
  base conj() { return base(x, -y); }
  base operator=(const base &o) {
    x = o.x;
    y = o.y;
    return *this;
  }
  base operator+(const base &o) const { return base(x + o.x, y + o.y); }
  base operator-(const base &o) const { return base(x - o.x, y - o.y); }
  base operator*(const base &o) const {
    return base(x * o.x - y * o.y, y * o.x + x * o.y);
  }
  base operator*(const double num) const { return base(x * num, y * num); }
  base operator/(const double num) const { return base(x / num, y / num); }
};
long long col[maxn];
vector<long long> adj[maxn];
long long st[maxn], ed[maxn], lzy[5 * maxn];
vector<long long> euler;
long long seg[5 * maxn], ans;
long long pow2[60];
void merge(long long a, long long b, long long c) { seg[c] = seg[a] | seg[b]; }
void build(long long node, long long s, long long e) {
  lzy[node] = -1;
  if (s == e) {
    seg[node] = (pow2[col[euler[s]] - 1]);
    return;
  }
  build(2 * node, s, (s + e) / 2);
  build(2 * node + 1, (s + e) / 2 + 1, e);
  merge(2 * node, 2 * node + 1, node);
}
void rmv(long long node, long long s, long long e) {
  if (lzy[node] == -1) return;
  seg[node] = (pow2[(lzy[node] - 1)]);
  if (s != e) {
    lzy[2 * node] = lzy[node];
    lzy[2 * node + 1] = lzy[node];
  }
  lzy[node] = -1;
}
void upd(long long node, long long s, long long e, long long l, long long r,
         long long val) {
  rmv(node, s, e);
  if (l > e || r < s) return;
  if (s >= l && e <= r) {
    lzy[node] = val;
    rmv(node, s, e);
    return;
  }
  upd(2 * node, s, (s + e) / 2, l, r, val);
  upd(2 * node + 1, (s + e) / 2 + 1, e, l, r, val);
  merge(2 * node, 2 * node + 1, node);
}
void quer(long long node, long long s, long long e, long long l, long long r) {
  rmv(node, s, e);
  if (l > e || r < s) return;
  if (s >= l && e <= r) {
    ans |= seg[node];
    return;
  }
  quer(2 * node, s, (s + e) / 2, l, r);
  quer(2 * node + 1, (s + e) / 2 + 1, e, l, r);
}
void df(long long no, long long p) {
  euler.push_back(no);
  st[no] = euler.size() - 1;
  for (auto x : adj[no]) {
    if (x != p) {
      df(x, no);
    }
  }
  ed[no] = euler.size() - 1;
}
signed main() {
  long long n, m, u, v, t, tt;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pow2[0] = 1;
  for (long long i = 0; i < 59; i++) {
    pow2[i + 1] = pow2[i] * 2;
  }
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> col[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  df(0, 0);
  build(1, 0, euler.size() - 1);
  for (long long i = 0; i < m; i++) {
    cin >> t;
    if (t == 1) {
      cin >> u >> v;
      u--;
      upd(1, 0, euler.size() - 1, st[u], ed[u], v);
    } else {
      cin >> u;
      u--;
      ans = 0;
      quer(1, 0, euler.size() - 1, st[u], ed[u]);
      tt = 0;
      for (long long i = 0; i < 60; i++) {
        if (ans & (pow2[i])) tt++;
      }
      cout << (tt) << "\n";
    }
  }
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 100;
const long long MaxN = 1e5 + 100;
const long long mod = 1e9 + 7;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
inline long long fast_expo(long long base, long long power,
                           long long modulo = mod) {
  long long x = base, cnt = power, ans = 1;
  while (cnt) {
    if (cnt & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    cnt >>= 1;
  }
  long long tmp = ans;
  return tmp;
}
inline long long fib(long long n, long long a = 1, long long b = 1,
                     long long c = 1, long long d = 0, long long acca = 0,
                     long long accb = 1, long long m = mod) {
  if (n == 0) return acca;
  if (n & 1)
    return fib(n / 2, ((a * a) % m + (b * c) % m) % m,
               ((a * b) % m + (b * d) % m) % m, (c * (a + d) % m) % m,
               ((c * b) % m + (d * d) % m) % m,
               ((a * acca) % m + (b * accb) % m) % m,
               ((c * acca) % m + (d * accb) % m) % m, m);
  else
    return fib(n / 2, ((a * a) % m + (b * c) % m) % m,
               ((a * b) % m + (b * d) % m) % m, (c * (a + d) % m) % m,
               ((c * b) % m + (d * d) % m) % m, acca, accb, m);
}
struct base {
  double x, y;
  base() {
    x = 0;
    y = 0;
  }
  base(double a) {
    x = a;
    y = 0;
  }
  base(double a, double b) {
    x = a;
    y = b;
  }
  base conj() { return base(x, -y); }
  base operator=(const base &o) {
    x = o.x;
    y = o.y;
    return *this;
  }
  base operator+(const base &o) const { return base(x + o.x, y + o.y); }
  base operator-(const base &o) const { return base(x - o.x, y - o.y); }
  base operator*(const base &o) const {
    return base(x * o.x - y * o.y, y * o.x + x * o.y);
  }
  base operator*(const double num) const { return base(x * num, y * num); }
  base operator/(const double num) const { return base(x / num, y / num); }
};
long long col[maxn];
vector<long long> adj[maxn];
long long st[maxn], ed[maxn], lzy[5 * maxn];
vector<long long> euler;
long long seg[5 * maxn], ans;
long long pow2[60];
void merge(long long a, long long b, long long c) { seg[c] = seg[a] | seg[b]; }
void build(long long node, long long s, long long e) {
  lzy[node] = -1;
  if (s == e) {
    seg[node] = (pow2[col[euler[s]] - 1]);
    return;
  }
  build(2 * node, s, (s + e) / 2);
  build(2 * node + 1, (s + e) / 2 + 1, e);
  merge(2 * node, 2 * node + 1, node);
}
void rmv(long long node, long long s, long long e) {
  if (lzy[node] == -1) return;
  seg[node] = (pow2[(lzy[node] - 1)]);
  if (s != e) {
    lzy[2 * node] = lzy[node];
    lzy[2 * node + 1] = lzy[node];
  }
  lzy[node] = -1;
}
void upd(long long node, long long s, long long e, long long l, long long r,
         long long val) {
  rmv(node, s, e);
  if (l > e || r < s) return;
  if (s >= l && e <= r) {
    lzy[node] = val;
    rmv(node, s, e);
    return;
  }
  upd(2 * node, s, (s + e) / 2, l, r, val);
  upd(2 * node + 1, (s + e) / 2 + 1, e, l, r, val);
  merge(2 * node, 2 * node + 1, node);
}
void quer(long long node, long long s, long long e, long long l, long long r) {
  rmv(node, s, e);
  if (l > e || r < s) return;
  if (s >= l && e <= r) {
    ans |= seg[node];
    return;
  }
  quer(2 * node, s, (s + e) / 2, l, r);
  quer(2 * node + 1, (s + e) / 2 + 1, e, l, r);
}
void df(long long no, long long p) {
  euler.push_back(no);
  st[no] = euler.size() - 1;
  for (auto x : adj[no]) {
    if (x != p) {
      df(x, no);
    }
  }
  ed[no] = euler.size() - 1;
}
signed main() {
  long long n, m, u, v, t, tt;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pow2[0] = 1;
  for (long long i = 0; i < 59; i++) {
    pow2[i + 1] = pow2[i] * 2;
  }
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> col[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  df(0, 0);
  build(1, 0, euler.size() - 1);
  for (long long i = 0; i < m; i++) {
    cin >> t;
    if (t == 1) {
      cin >> u >> v;
      u--;
      upd(1, 0, euler.size() - 1, st[u], ed[u], v);
    } else {
      cin >> u;
      u--;
      ans = 0;
      quer(1, 0, euler.size() - 1, st[u], ed[u]);
      tt = 0;
      for (long long i = 0; i < 60; i++) {
        if (ans & (pow2[i])) tt++;
      }
      cout << (tt) << "\n";
    }
  }
}

```