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.*;
import java.util.*;
// import static java.lang.System.*;
// import static java.lang.Math.*;
/*
* Codeforces: https://codeforces.com/contest/620/problem/E
* Tags: DFS, Segment Tree, BitSet, Euler_Tour_3 (Time_in, Time_out)
*/
public class ProblemE
{
    List<Integer> tree[];
    int timer=0;
    int[] C,A,tin,tout;
    long[] ST,lazy;
    void run() {
        int tc=1;
        StringBuilder sb = new StringBuilder();
        while(tc-->0) {
            int n=ni(),m=ni();
            C=new int[n];
            A=new int[n];
            tin=new int[n+1];
            tout=new int[n+1];
            tree=new ArrayList[n+1];
            ST=new long[n<<2];
            lazy=new long[n<<2];
            for(int i=1;i<=n;i++) {
                A[i-1]=ni();
                tree[i]=new ArrayList<>();
            }
            
            for(int i=0;i<n-1;i++) {
                int x=ni(),y=ni();
                tree[x].add(y);
                tree[y].add(x);
            }
            // euler tour 3
            dfs(1,0);
            build(1,0,n);
            // for(int i=0;i<n;i++) C[i]=A[flat_tree.get(i)-1];
            // C=A.clone();
            // out.println(Arrays.toString(tin));
            // out.println(Arrays.toString(tout));
            // out.println(flat_tree);
            // out.close();
            // out.println(Arrays.toString(C));
            while(m-->0) {
                if(ni()==1) {
                    int vk=ni(),ck=ni();
                    // out.println(vk+" "+tin[vk]+" "+tout[vk]);
                    // for(int i=tin[vk]-1;i<tout[vk];i++) 
                    update(tin[vk]-1,tout[vk],ck,1,0,n);
                    // if(tin[vk]==tout[vk]) update(tin[vk]-1,ck,1,0,n);
                    // out.println(Arrays.toString(C));
                }
                else {
                    int ct=0,vk=ni(); 
                    long x=query(tin[vk]-1,tout[vk],1,0,n);
                    for(;x>0;x&=x-1,ct++);
                    sb.append(ct).append("\n");
                    // if(tin[vk]==tout[vk]) {
                    //     BitSet b=query(tin[vk]-1,tout[vk],1,0,n);
                    //     // out.println(b);
                    //     sb.append(b.cardinality()).append("\n");
                    // }
                    // else {
                    //     BitSet b=query(tin[vk]-1,tout[vk],1,0,n);
                    //     // out.println(b);
                    //     sb.append(b.cardinality()).append("\n");
                    // }
                }
                // out.println(Arrays.toString(ST));
            }
        }
        out.println(sb);
        out.flush(); 
        out.close();
    }
    // euler tour 3
    void dfs(int cur, int par) {
        tin[cur]=++timer;
        C[tin[cur]-1]=A[cur-1];
        for(int i=0,sz=tree[cur].size();i<sz;i++) 
            if(tree[cur].get(i)!=par) 
                dfs(tree[cur].get(i),cur);
        tout[cur]=timer;
    }
    void build(int x, int l, int r) {
        if(l==r-1) { ST[x]=1l<<C[l]; return; }
        int mid=(l+r)>>1;
        build(lc(x),l,mid);
        build(rc(x),mid,r);
        ST[x]=ST[lc(x)];
        ST[x]|=ST[rc(x)];
    }
    void push(int left, int right, int nd) {
        if (lazy[nd] != 0) {
            ST[nd] = 1l << lazy[nd];
            if (left != right-1) {
                lazy[nd << 1] = lazy[nd];
                lazy[nd << 1 | 1] = lazy[nd];
            }
            lazy[nd] = 0;
        }
    }
    void update(int L, int R, int val, int x, int l, int r) {
        push(l, r, x);
        if(l>=R || r<=L) return;
        if (l>=L  && r<=R) {
            lazy[x]=val;
            push(l, r, x);
            // ST[x]=1l<<val;
            // C[l]|=1<<val;
            return;
        }
        int mid=(l+r)>>1;
        update(L,R,val,lc(x),l,mid);
        update(L,R,val,rc(x),mid,r);
        ST[x]=ST[lc(x)];
        ST[x]|=ST[rc(x)];
    }
    long query(int L, int R, int x, int l, int r) {
        push(l, r, x);
        if(l>=R || r<=L) return 0;
        if(l>=L && r<=R) return ST[x];
        int mid=(l+r)>>1;
        long v = query(L,R,lc(x),l,mid);
        v|=query(L,R,rc(x),mid,r);
        return v;
    }
    int lc(int x) { return (x<<1); }
    int rc(int x) { return (x<<1)|1; }
    // BitSet merge(BitSet x, BitSet y) {
    //     BitSet bs = new BitSet();
    //     bs.or(x);
    //     bs.or(y);
    //     return bs;
    // }
    public static void main(String[] args)throws Exception {
        // try { 
            // new ProblemE().run();
            new ProblemE("ONLINE_JUDGE").run();
        // } catch(Exception e) {}
    }

    FastReader sc=null;PrintWriter out = null;
    public ProblemE()throws Exception {
        sc = new FastReader(new FileInputStream("input.txt"));
        out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
    }
    public ProblemE(String JUDGE) {
        sc = new FastReader(System.in);
        out = new PrintWriter(System.out);      
    }
    
    String ns() { return sc.next(); }
    int ni() { return sc.nextInt(); }
    long nl() { return sc.nextLong(); }
    int[] ni(int n) {
        int a[]=new int[n];
        for(int i=0;i<n;a[i++]=ni());
        return a;
    }
    long[] nl(int n) {
        long a[]=new long[n];
        for(int i=0;i<n;a[i++]=nl());
        return a;
    }
    
    int[][] ni(int n,int m) {
        int a[][]=new int[n][m];
        for(int i=0;i<n;i++) 
            for(int j=0;j<m;j++)
                a[i][j]=ni();
        return a;
    }
    long[][] nl(int n,int m) {
        long a[][]=new long[n][m];
        for(int i=0;i<n;i++) 
            for(int j=0;j<m;j++)
                a[i][j]=nl();
        return a;
    }
    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;
        public FastReader(InputStream stream) {
            this.stream = stream;
        }

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

        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 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 = res*1L*10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res *1L* sgn;
        }
        
        public String next() {
            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 boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }
    }
}