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 java.awt.Point;

public class CF_620E {
    static ArrayList<ArrayList<Integer>> adj;
    static int cnt;

    static int[] first, last;

    public static void main(String args[]) throws Exception {
        BufferedScanner in = new BufferedScanner(System.in);
        BufferedPrinter out = new BufferedPrinter(System.out);

        int n = in.nextInt(), m = in.nextInt();
        int[] cs = in.nextN(n);

        adj = getAdj(n);
        for (int i = 0; i < n - 1; i++) {
            int u = in.nextInt() - 1, v = in.nextInt() - 1;
            adj.get(u).add(v);
            adj.get(v).add(u);
        }

        first = new int[n];
        last = new int[n];

        ett(0, -1);

        LazyST st = new LazyST(cnt, cs);
        for(int i = 0; i < m; i++){
            if(in.nextInt() == 1){
                int v = in.nextInt() - 1;
                long c = 1L << in.nextInt();

                st.update(first[v], last[v], new PU(c));
            }else {
                int v = in.nextInt() - 1;

                long val = st.query(first[v], last[v]).n;
                int ret = 0;
                for(int j = 1; j <= 60; j++){
                    if((val & (1L << j)) != 0) ret++;
                }
                out.println(ret);
            }
        }

        out.close();
        in.close();
    }

    static void ett(int n, int p) {
        first[n] = cnt++;
        for (Integer v : adj.get(n)) {
            if (v != p) ett(v, n);
        }
        last[n] = cnt++;
    }

    static class PII {
        final long n;

        PII(long n) {
            this.n = n;
        }

        PII update(PU o) {
            return o.n < 1? this: new PII(o.n);
        }

        PII combine(PII o) {
            return new PII(this.n | o.n);
        }

        static PII init = new PII(0);
    }

    static class PU {
        static int time;
        int created = time++;
        final long n;

        PU(long n) {
            this.n = n;
        }

        PU combine(PU o) {
            return o.created > created? o: this;
        }

        static PU init = new PU(0);
    }

    static class LazyST {
        PII[] tree;
        PU[] updates;
        int n;

        LazyST(int n, int[] arr) {
            n = (int) Math.pow(2, Math.ceil(Math.log(n) / Math.log(2)));

            tree = new PII[2 * n - 1];
            updates = new PU[tree.length];

            Arrays.fill(tree, PII.init);
            Arrays.fill(updates, PU.init);

            for(int i = 0; i < arr.length; i++){
                tree[n - 1 + first[i]] = new PII(1L << arr[i]);
            }
            for(int i = tree.length - 1; i >= 0; i--) recalc(i);

            this.n = n;
        }

        void set(int idx, PII k) {
            int curr = idx + n - 1;
            tree[curr] = k;

            while (curr > 0) {
                curr = p(curr);
                recalc(curr);
            }
        }

        void update(int left, int right, PU diff) {
            update(0, 0, n - 1, diff, left, right);
        }

        void processLazy(int idx) {
            tree[idx] = tree[idx].update(updates[idx]);

            if (l(idx) < tree.length) updates[l(idx)] = updates[l(idx)].combine(updates[idx]);
            if (r(idx) < tree.length) updates[r(idx)] = updates[r(idx)].combine(updates[idx]);

            updates[idx] = PU.init;
        }

        public void update(int idx, int il, int ir, PU delta, int ul, int ur) {
            if (ul <= il && ir <= ur) updates[idx] = updates[idx].combine(delta);

            processLazy(idx);

            if (il > ur || ir < ul || (ul <= il && ir <= ur)) return;

            int mid = (il + ir) / 2;
            update(l(idx), il, mid, delta, ul, ur);
            update(r(idx), mid + 1, ir, delta, ul, ur);

            recalc(idx);
        }

        public PII query(int left, int right) {
            return query(0, left, right, 0, n - 1);
        }

        public PII query(int idx, int ql, int qr, int il, int ir) {
            processLazy(idx);

            if (ql <= il && ir <= qr) return tree[idx];

            PII ret = null;
            int mid = (il + ir) / 2;

            if (ql <= mid) ret = query(l(idx), ql, qr, il, mid);
            if (qr >= mid + 1) ret = combine(ret, query(r(idx), ql, qr, mid + 1, ir));
            return ret;
        }

        PII combine(PII a, PII b) {
            if (a == null) return b;
            return a.combine(b);
        }

        public void recalc(int idx) {
            if (l(idx) < tree.length) {
                tree[idx] = tree[l(idx)];
                if (r(idx) < tree.length) {
                    tree[idx] = combine(tree[idx], tree[r(idx)]);
                }
            }
        }

        int p(int n) {
            return (n - 1) / 2;
        }

        int l(int n) {
            return 2 * n + 1;
        }

        int r(int n) {
            return l(n) + 1;
        }

    }

    static <T> ArrayList<ArrayList<T>> getAdj(int n) {
        ArrayList<ArrayList<T>> ret = new ArrayList<>();
        for (int i = 0; i < n; i++) ret.add(new ArrayList<>());

        return ret;
    }

    static class BufferedPrinter {
        PrintWriter out;

        BufferedPrinter(OutputStream out) {
            this(new OutputStreamWriter(out));
        }

        BufferedPrinter(Writer out) {
            this.out = new PrintWriter(new BufferedWriter(out));
        }

        void print(Object... os) {
            for (int i = 0; i < os.length; i++) {
                if (i != 0) out.print(' ');
                out.print(os[i]);
            }
        }

        void println(Object... os) {
            print(os);
            out.println();
        }

        void close() {
            out.close();
        }

        void flush() {
            out.flush();
        }
    }

    static class BufferedScanner {
        private final InputStream in;
        private final byte[] buf = new byte[1 << 13];

        int pos, count;

        BufferedScanner(InputStream in) throws IOException {
            this.in = in;
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        int[] nextN(int n) throws IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) ret[i] = this.nextInt();
            return ret;
        }

        long[] nextNL(int n) throws IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) ret[i] = this.nextLong();
            return ret;
        }

        private int read() {
            if (count == -1) err();

            try {
                if (pos >= count) {
                    pos = 0;
                    count = in.read(buf);
                    if (count <= 0) return -1;
                }
            } catch (IOException e) {
                err();
            }
            return buf[pos++];
        }

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

        private int nextToken() {
            int ret;
            do {
                ret = read();
            } while (isSpace(ret));
            return ret;
        }

        int nextInt() {
            int sign = 1;
            int c = nextToken();
            if (c == '-') {
                sign = -1;
                c = read();
            }

            int ret = 0;
            do {
                if (c < '0' || c > '9') err();
                ret = ret * 10 + c - '0';
                c = read();
            } while (!isSpace(c));
            return sign * ret;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            int c = nextToken();
            do {
                sb.append((char) c);
                c = read();
            } while (!isSpace(c));
            return sb.toString();
        }

        private void err() {
            throw new InputMismatchException();
        }

        void close() throws IOException {
            in.close();
        }

    }
}