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.text.DecimalFormat;

public class Main{
    final long mod = (int)1e9+7, IINF = (long)1e19;
    final int MAX = (int)1e4+1, MX = (int)1e7+1, INF = (int)1e9;
    DecimalFormat df = new DecimalFormat("0.0000000000000");
    double eps = 1e-9;
    FastReader in;
    PrintWriter out;
    static boolean multipleTC = false, memory = false;

    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 26).start();
        else new Main().run();
    }

    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, t = (multipleTC)?ni():1; i<=t; i++)solve(i);
        out.flush();    
        out.close();
    }
    int t = -1;
    void solve(int TC) throws Exception{
        int n = ni(), m = ni();
        long[] a = new long[n];
        for(int i = 0; i< n; i++)a[i] = ni()-1;
        int[][] g = new int[n][], edge = new int[n-1][2];
        int[] cnt = new int[n];
        for(int i = 0; i< n-1; i++){
            edge[i] = new int[]{ni()-1, ni()-1};
            cnt[edge[i][0]]++;cnt[edge[i][1]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< n-1; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = edge[i][1];
            g[edge[i][1]][--cnt[edge[i][1]]] = edge[i][0];
        }
        int[][] ti = new int[n][2];
        dfs(g,ti,0,-1);
        long[] b = new long[n];
        for(int i = 0; i< n; i++)b[ti[i][0]] = a[i];
        SegTree t = new SegTree(b);
        for(int i = 0; i< m; i++){
            int ty = ni();
            int v = ni()-1;
            if(ty==1)t.update(ti[v][0], ti[v][1], i+1,ni()-1);
            else pn(t.query(ti[v][0], ti[v][1]));
        }
    }
    class SegTree{
        int m = 1;
        long[][] base, lazy;
        public SegTree(long[] a){
            while(m<a.length)m<<=1;
            base = new long[m<<1][2];
            lazy = new long[m<<1][];
            for(int i = m; i< m+a.length; i++)base[i][1] = 1l<<a[i-m];
            for(int i = m-1; i> 0; i--)base[i][1] = base[i<<1][1]|base[i<<1|1][1];
            for(int i = 0; i< lazy.length; i++)lazy[i] = new long[]{-1,-1};
        }
        void push(int ll, int rr,int i){
            if(lazy[i][0]!=-1){
                if(base[i][0]<lazy[i][0]){
                    base[i][0] = lazy[i][0];
                    base[i][1] = 1l<<lazy[i][1];
                }
                if(ll!=rr){
                    if(lazy[i<<1][0]<lazy[i][0]){
                        lazy[i<<1][0] = lazy[i][0];
                        lazy[i<<1][1] = lazy[i][1];
                    }
                    if(lazy[i<<1|1][0]<lazy[i][0]){
                        lazy[i<<1|1][0] = lazy[i][0];
                        lazy[i<<1|1][1] = lazy[i][1];
                    }
                }
                lazy[i][0] = -1;
                lazy[i][1] = -1;
            }
        }
        void update(int l, int r, int t, int c){
            update(l,r,0,m-1,1, t,c);
        }
        void update(int l, int r, int ll, int rr, int i, int t, int c){
            push(ll,rr,i);
            if(l==ll && r==rr){
                if(base[i][0]<t){
                    base[i][0] = t;
                    base[i][1] = 1l<<c;
                }
                if(ll!=rr){
                    if(lazy[i<<1][0]<t){
                        lazy[i<<1][0] = t;
                        lazy[i<<1][1] = c;
                    }
                    if(lazy[i<<1|1][0]<t){
                        lazy[i<<1|1][0] = t;
                        lazy[i<<1|1][1] = c;
                    }
                }
                return;
            }
            int mid = (ll+rr)>>1;
            if(r<=mid){
                push(mid+1,rr,i<<1|1);
                update(l,r,ll,mid,i<<1,t,c);
            }
            else if(l>mid){
                push(ll,mid,i<<1);
                update(l,r,mid+1,rr,i<<1|1,t,c);
            }
            else{
                update(l,mid,ll,mid,i<<1,t,c);
                update(mid+1,r,mid+1,rr,i<<1|1,t,c);
            }
            base[i][0] = t;
            base[i][1] = base[i<<1][1]|base[i<<1|1][1];
        }
        int query(int l, int r){
            return bit(query(l,r,0,m-1,1));
        }
        long query(int l, int r, int ll, int rr, int i){
            push(ll,rr,i);
            if(l==ll && r==rr)return base[i][1];
            int mid = (ll+rr)>>1;
            if(r<=mid)return query(l,r,ll,mid,i<<1);
            else if(l>mid)return query(l,r,mid+1,rr,i<<1|1);
            else return query(l,mid,ll,mid,i<<1)|query(mid+1,r,mid+1,rr,i<<1|1);
        }
    }
    int bit(long a){
        return (a==0)?0:(1+bit(a&(a-1)));
    }
    void dfs(int[][] g, int[][] ti,int u, int p){
        ti[u][0] = ++t;
        for(int v:g[u])if(v!=p)dfs(g,ti,v,u);
        ti[u][1] = t;
    }
    long sum(long f, long r, long n){
        if(r==1)return mul(f,n);
        return mul(f, mul(add(modPow(r, n), -1), modPow(add(r,-1), mod-2)));
    }
    long mul(long a, long b){
        if(a>=mod)a%=mod;
        if(b>=mod)b%=mod;
        a*=b;
        if(a>=mod)a%=mod;
        return a;
    }
    long add(long a, long b){
        if(Math.abs(a)>=mod)a%=mod;
        if(a<0)a+=mod;
        if(Math.abs(b)>=mod)b%=mod;
        if(b<0)b+=mod;
        a+=b;
        if(Math.abs(a)>=mod)a%=mod;
        return a;
    }
    long modPow(long a, long p){
        long o = 1;
        while(p>0){
            if(p%2==1)o = (a*o)%mod;
            a = (a*a)%mod;
            p>>=1;
        }
        return o;
    }
        
    long[] reverse(long[] a){
        long[] o = new long[a.length];
        for(int i = 0; i< a.length; i++)o[i] = a[a.length-i-1];
        return o;   
    }

    int[] sort(int[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        int[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    long[] sort(long[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        long[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    int[] ia(int ind,int n){
        int[] out = new int[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = ni();
        return out;
    }

    long[] la(int ind, int n){
        long[] out = new long[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = nl();
        return out;
    }

    double[] da(int ind, int n){
        double[] out = new double[ind+n];
        for(int i = 0; i< n; i++)out[ind+i] = nd();
        return out;
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        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;
        }
    }
}