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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution{
	
	
	static int n, m;
	static ArrayList<Integer>[] g;
	static int[] c;
	static int[] start, end, trail;
	static int timer;
	
	
	
    public static void main(String[] args) throws IOException {
    	
		
    	FastScanner fs = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    		
    	int tt = 1;
    	while(tt-->0) {
    		
    		n = fs.nextInt();
    		m = fs.nextInt();
    		
    		c = fs.readArray(n);
    		
    		g = new ArrayList[n];
    		for(int i=0;i<n;i++) g[i] = new ArrayList<Integer>();
    		
    		for(int i=0;i<n-1;i++) {
    			int u = fs.nextInt()-1, v = fs.nextInt()-1;
    			g[u].add(v);
    			g[v].add(u);
    		}
    		
    		trail = new int[n];
    		start = new int[n];
    		end = new int[n];
    		
    		dfs(0, -1);
    		
    		SegTree tree = new SegTree(n);
    		for(int i=0;i<n;i++) {
    			tree.update(i, trail[i], 0, n-1, 0);
    		}
    		
    		
    		while(m-->0) {
    			int t = fs.nextInt();
    			if(t==1) {
    				int v = fs.nextInt()-1, c = fs.nextInt();
    				tree.rangeupdate(start[v], end[v], c, 0, n-1, 0);
    				int f = 1;
    			}
    			else {
    				int v = fs.nextInt()-1;
    				long num = tree.query(start[v], end[v], 0, n-1, 0);
    				int cnt = 0;
    				for(int i=1;i<=60;i++) {
    					if((num&(1L<<i))!=0) cnt++;
    				}
    				out.println(cnt);
    			}
    			
    			
    			
    			
    			
    			
    			
    		}
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    		
    	}
    	
    	out.close();
    	
    }
    
    
    static void dfs(int v, int p) {
    	trail[timer] = c[v]; 
    	start[v] = timer;
    	timer++;
    	for(int u: g[v]) {
    		if(u==p) continue;
    		dfs(u, v);
    	}
    	end[v] = timer-1;
    }
    
    
    
    static class SegTree{
    	long[] tree;
    	int[] lazy;
    	
    	SegTree(int n){
    		tree = new long[4*n];
    		lazy = new int[4*n];
    	}
    	
    	void update(int ind, int c, int ns, int ne, int node) {
    		if(ind<ns || ind>ne) return;
    		if(ns==ne) {
    			tree[node] = (1L<<c);
    			return;
    		}
    		int mid = (ns+ne)/2;
    		update(ind, c, ns, mid, 2*node+1);
    		update(ind, c, mid+1, ne, 2*node+2);
    		tree[node] = tree[2*node+1] | tree[2*node+2];
    	}
    	
    	void propagate(int ns, int ne, int node) {
    		int c = lazy[node];
    		tree[node] =  (1L<<c);
    		if(ns!=ne) {
    			lazy[2*node+1] = c;
    			lazy[2*node+2] = c;
    		}
    		lazy[node] = 0;
    	}
    	
    	void rangeupdate(int qs, int qe, int c, int ns, int ne, int node) {
    		if(lazy[node]>0) propagate(ns, ne, node);
    		if(ns>qe || ne<qs) return;
    		if(ns>=qs && ne<=qe) {
    			tree[node] = (1L<<c);
    			if(ns!=ne) {
    				lazy[2*node+1] = c;
    				lazy[2*node+2] = c;
    			}
    			return;
    		}
    		int mid = (ns+ne)/2;
    		rangeupdate(qs, qe, c, ns, mid, 2*node+1);
    		rangeupdate(qs, qe, c, mid+1, ne, 2*node+2);
    		tree[node] = tree[2*node+1] | tree[2*node+2];
    	}
    	
    	long query(int qs, int qe, int ns, int ne, int node) {
    		if(lazy[node]>0) propagate(ns, ne, node);
    		if(ns>qe || ne<qs) return 0L;
    		if(ns>=qs && ne<=qe) return tree[node];
    		int mid = (ns+ne)/2;
    		return query(qs, qe, ns, mid, 2*node+1) | query(qs, qe, mid+1, ne, 2*node+2);
    	}
    	
    }
    
    
    
    
    
    
    

    
    
    static final Random random=new Random();
    
    static <T> void shuffle(T[] arr) {
    	int n = arr.length;
    	for(int i=0;i<n;i++	) {
    		int k = random.nextInt(n);
    		T temp = arr[k]; arr[k] = arr[i]; arr[i] = temp;
    	}
    }
    
    	
    static void ruffleSort(int[] a) {
    	int n=a.length;//shuffle, then sort 
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); int temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }
    
    static void ruffleSort(long[] a) {
    	int n=a.length;//shuffle, then sort 
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); long temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }
   
  
    
    static void reverse(int[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++){
    		int temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }
    
    static void reverse(long[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++){
    		long temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }
    
    
    static <T> void reverse(T[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++) {
    		T temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }
    	
    	
    static class FastScanner{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
     
    	public String next(){
    		while(!st.hasMoreElements()){
    			try{
    				st = new StringTokenizer(br.readLine());
    			} catch(IOException e){
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}
    		
    	public String nextLine() throws IOException {
    		return br.readLine();
    	}
    		
    	public int nextInt(){
    		return Integer.parseInt(next());
    	}
     
    	public int[] readArray(int n){
    		int[] a = new int[n];
    		for(int i=0;i<n;i++)
    			a[i] = nextInt();
    		return a;
    	}
    		
    	public long nextLong() {
    		return Long.parseLong(next());
    	}
    		
    	public char nextChar() {
    		return next().toCharArray()[0];
    	}
    }
   	
}