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 JAVA):

Solution:
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    static void dfs(int node, ArrayList<Integer> l[], boolean visited[]){
        visited[node] = true;
        in[node] = ++T;

        for(Integer child : l[node]){
            if(visited[child])
                continue;
            dfs(child, l, visited);
        }

        out[node] = T;
    }

    static void buildTree(int s,int e,int index){
        if(s == e){
            tree[index] = (long)Math.pow(2l, arr[s]);
            return;
        }

        int mid = (s+e)/2;
        buildTree(s,mid, 2*index);
        buildTree(mid+1,e, 2*index+1);

        tree[index] = (tree[2*index] | tree[2*index+1]);
    }

    static long query(int qs,int qe,int s,int e,int index){

         //No Overlap
        if(qs > e || qe < s)
            return 0;

         lazy_push(s, e, index);
        //Complete Overlap
        if(qs <= s && qe >= e)
            return tree[index];

        //Partial Overlap- Call on both sides and update the current ans
        int mid = s + (e - s)/2;
        return (query(qs,qe,s,mid,2*index) | query(qs,qe,mid+1,e,2*index+1));
    }

    static void lazy_push(int l ,int r, int idx){
        if(lazy[idx] == 0)
            return ;
        tree[idx] = lazy[idx];

        if(l != r){
            lazy[2 * idx] = (lazy[2 * idx + 1] = lazy[idx]);
        }

        lazy[idx] = 0;
    }

    static void updateRange(int qs, int qe, int s,int e, int c,int index){
        lazy_push(s, e, index);
        //Out of bound
        if(qs > e || qe < s)
            return ;

        if(s >= qs && qe >= e){
            lazy[index] = (long)Math.pow(2l, c);
            lazy_push(s, e, index);
            return ;
        }

        int mid = s + (e - s)/2;
        updateRange(qs, qe, s, mid, c, 2* index);
        updateRange(qs, qe, mid + 1, e, c, 2* index + 1);

        tree[index] = (tree[2*index] | tree[2*index+1]);
    }

    public static void process(int test_number)throws IOException
    {
        int n = ni(), m = ni(), col[] = new int[n+1];
        arr = new int[n+1];
        in = new int[n+1];
        out = new int[n+1];
        lazy = new long[4*n + 4];
        tree = new long[4*n + 4];
        boolean visited[] = new boolean[n+1];
        T = 0;
        PrintWriter pt = new PrintWriter(System.out);

        for(int i = 1; i <= n; i++)
            col[i] = ni();

        ArrayList<Integer> l[] = new ArrayList[n+1];
        for(int i = 0; i <= n; i++)
            l[i] = new ArrayList<>();

        for(int i = 1; i < n; i++){
            int u = ni(), v = ni();
            l[u].add(v);
            l[v].add(u);
        }

        dfs(1, l, visited);
        for(int i = 1; i <= n; i++){
            arr[in[i]] = col[i];
        }

        buildTree(1, n, 1);

        while(m-- > 0){
            int type  = ni();

            if(m == 0) trace(tree);

            if(type == 2){
                int v = ni();
                long mask = query(in[v], out[v], 1, n, 1);
                pt.println(bit(mask));
            }
            else{
                int v = ni(), c = ni();
                updateRange(in[v], out[v], 1, n, c, 1); 
            }
        }
        pt.flush();
    }
 
    static final long mod = (long)1e9+7l;
    static int in[], out[], T, arr[];
    static long lazy[], tree[];

    static FastReader sc;
    public static void main(String[]args)throws IOException
    {
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
       // t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}