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:
/**
 * DA-IICT
 * Author : PARTH PATEL
 */
import java.io.*;
import java.math.*;
import java.util.*;

import javax.swing.text.Segment;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;


public class E620 {

	public static int mod = 1000000007;
	static FasterScanner in = new FasterScanner();
	static PrintWriter out = new PrintWriter(System.out);
	static int n;
	static int[] color;
	static ArrayList<Integer>[] adjacencylist;
	static boolean[] visited;
	static long[] tree;
	static int time=0;
	static int[] eulertour;
	static int[] tin;
	static int[] tout;
	static long[] lazy;
	public static void dfs(int vertex)
	{
		visited[vertex]=true;
		tin[vertex]=time;
		eulertour[time++]=vertex;
		for(int i : adjacencylist[vertex])
		{
			if(!visited[i])
				dfs(i);
		}
		tout[vertex]=time;
		eulertour[time++]=vertex;
	}
	public static void build(int node,int start,int end)
	{
		if(start==end)
		{
			tree[node]=((long)1<<color[eulertour[start]]);
		}
		else
		{
			int mid=(start+end)/2;
			build(2*node, start, mid);
			build(2*node+1, mid+1, end);
			tree[node]=tree[2*node]|tree[2*node+1];
		}
	}
	public static void updaterange(int node,int start,int end,int l,int r,int val)
	{
		if(lazy[node]!=0)
		{
			tree[node]=(long)1<<lazy[node];
			if(start!=end)
			{
				lazy[2*node]=lazy[node];
				lazy[2*node+1]=lazy[node];
			}
			lazy[node]=0;
		}
		if(start>end || start>r || end<l)
		{
			return;
		}
		if(start>=l && end<=r)
		{
			tree[node]=(long)1<<val;
			if(start!=end)
			{
			lazy[2*node]=val;
			lazy[2*node+1]=val;
			}
			return;
		}
		int mid=(start+end)/2;
		updaterange(2*node, start, mid, l, r, val);
		updaterange(2*node+1, mid+1, end, l, r, val);
		tree[node]=tree[2*node]|tree[2*node+1];
	}
	public static long queryrange(int node,int start,int end,int l,int r)
	{
		if(lazy[node]!=0)
		{
			tree[node]=(long)1<<lazy[node];
			if(start!=end)
			{
				lazy[2*node]=lazy[node];
				lazy[2*node+1]=lazy[node];
			}
			lazy[node]=0;
		}
		if(start>end || l>end || r<start)
			{
			return 0;
			}
		if(start>=l && end<=r)
		{
			return tree[node];
		}
		int mid=(start+end)/2;
		long p1=queryrange(2*node, start, mid, l, r);
		long p2=queryrange(2*node+1, mid+1, end, l, r);
		return (p1|p2);
	}
	public static int setbits(long n)
	{
		int count=0;
		for(int i=0;i<=63;i++)
		{
			if((n&((long)1<<i))!=0)
				count++;
		}
		return count;
	}
	public static void main(String[] args) {
		
		n=in.nextInt();
		int queries=in.nextInt();
		color=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			color[i]=in.nextInt();
		}
		adjacencylist=new ArrayList[n+1];
		visited=new boolean[n+1];
		eulertour=new int[2*n];
		tin=new int[n+1];
		tout=new int[n+1];
		tree=new long[2*4*n];
		lazy=new long[2*4*n];
		for(int i=1;i<=n;i++)
		{
			adjacencylist[i]=new ArrayList<>();
		}
		for(int i=1;i<=n-1;i++)
		{
			int u=in.nextInt();
			int v=in.nextInt();
			adjacencylist[u].add(v);
			adjacencylist[v].add(u);
		}
		dfs(1);
		build(1, 0, 2*n-1);
		while(queries-->0)
		{
			int type=in.nextInt();
			if(type==1)
			{
				int l=in.nextInt();
				int val=in.nextInt();
				updaterange(1, 0, 2*n-1, tin[l], tout[l], val);
			}
			else
			{
				int v=in.nextInt();
				long answer=queryrange(1, 0, 2*n-1, tin[v], tout[v]);
				out.println(setbits(answer));
			}
		}
		out.close();

	}

	public static long pow(long x, long n, long mod) {
		long res = 1;
		for (long p = x; n > 0; n >>= 1, p = (p * p) % mod) {
			if ((n & 1) != 0) {
				res = (res * p % mod);
			}
		}
		return res;
	}

	public static long gcd(long n1, long n2) {
		long r;
		while (n2 != 0) {
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	public static long lcm(long n1, long n2) {
		long answer = (n1 * n2) / (gcd(n1, n2));
		return answer;
	}

	static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}

}