Problem: You come home and fell some unpleasant smell. Where is it coming from?

You are given an array a. You have to answer the following queries: 

  1. You are given two integers l and r. Let ci be the number of occurrences of i in al: r, where al: r is the subarray of a from l-th element to r-th inclusive. Find the Mex of {c0, c1, ..., c109}
  2. You are given two integers p to x. Change ap to x. 



The Mex of a multiset of numbers is the smallest non-negative integer not in the set.

Note that in this problem all elements of a are positive, which means that c0 = 0 and 0 is never the answer for the query of the second type.

Input

The first line of input contains two integers n and q (1 ≤ n, q ≤ 100 000) — the length of the array and the number of queries respectively.

The second line of input contains n integers — a1, a2, ..., an (1 ≤ ai ≤ 109).

Each of the next q lines describes a single query.

The first type of query is described by three integers ti = 1, li, ri, where 1 ≤ li ≤ ri ≤ n — the bounds of the subarray.

The second type of query is described by three integers ti = 2, pi, xi, where 1 ≤ pi ≤ n is the index of the element, which must be changed and 1 ≤ xi ≤ 109 is the new value.

Output

For each query of the first type output a single integer — the Mex of {c0, c1, ..., c109}.

Example

Input

10 4
1 2 3 1 1 2 2 2 9 9
1 1 1
1 2 8
2 7 1
1 2 8


Output

2
3
2

Note

The subarray of the first query consists of the single element — 1. 

The subarray of the second query consists of four 2s, one 3 and two 1s.

The subarray of the fourth query consists of three 1s, three 2s and one 3.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        ProblemFMachineLearning solver = new ProblemFMachineLearning();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemFMachineLearning {
        final int BLK = 2300;
        int[] occur = new int[200000];
        int[] cnt = new int[200000];

        void add(int val) {
            cnt[occur[val]]--;
            occur[val]++;
            cnt[occur[val]]++;
        }

        void del(int val) {
            cnt[occur[val]]--;
            occur[val]--;
            cnt[occur[val]]++;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), Q = in.nextInt();
            int[] a = in.nextIntArray(n);
            ArrayList<Query> query = new ArrayList<>();
            ArrayList<int[]> modify = new ArrayList<>();
            for (int i = 0; i < Q; i++) {
                int op = in.nextInt();
                if (op == 1) {
                    Query q = new Query();
                    q.L = in.nextInt() - 1;
                    q.R = in.nextInt() - 1;
                    if (q.L > q.R) {
                        int t = q.L;
                        q.L = q.R;
                        q.R = t;
                    }
                    q.t = modify.size() - 1;
                    q.id = i;
                    q.belong1 = q.t / BLK;
                    q.belong2 = q.L / BLK;
                    query.add(q);
                } else {
                    int p = in.nextInt() - 1, x = in.nextInt();
                    modify.add(new int[]{p, x});
                }
            }
            int[] trans = new int[a.length + modify.size()];
            for (int i = 0; i < a.length; i++) {
                trans[i] = a[i];
            }
            for (int i = 0; i < modify.size(); i++) {
                trans[i + a.length] = modify.get(i)[1];
            }
            ArrayUtil.shrink(trans);
            for (int i = 0; i < a.length; i++) {
                a[i] = trans[i];
            }
            for (int i = 0; i < modify.size(); i++) {
                int p = modify.get(i)[0];
                int v = trans[i + a.length];
                modify.set(i, new int[]{p, v, a[p]});
                a[p] = v;
            }

            query.sort(new Comparator<Query>() {

                public int compare(Query o1, Query o2) {
                    if (o1.belong1 != o2.belong1) {
                        return o1.belong1 - o2.belong1;
                    } else if (o1.belong2 != o2.belong2) {
                        return o1.belong2 - o2.belong2;
                    } else {
                        return o1.R - o2.R;
                    }
                }
            });
            int[] ans = new int[Q];
            Arrays.fill(ans, -1);
            int nowT = modify.size(), nowL = 0, nowR = 0;
            for (Query q : query) {
                while (nowT <= q.t) {
                    int p = modify.get(nowT)[0];
                    int v = modify.get(nowT)[1];
                    int pre = modify.get(nowT)[2];
                    if (p >= nowL && p < nowR) {
                        del(pre);
                        add(v);
                    }
                    a[p] = v;
                    nowT++;
                }
                while (nowT > q.t + 1) {
                    nowT--;
                    int p = modify.get(nowT)[0];
                    int v = modify.get(nowT)[1];
                    int pre = modify.get(nowT)[2];
                    if (p >= nowL && p < nowR) {
                        del(v);
                        add(pre);
                    }
                    a[p] = pre;
                }
                while (nowR <= q.R) add(a[nowR++]);
                while (nowL > q.L) add(a[--nowL]);
                while (nowL < q.L) del(a[nowL++]);
                while (nowR > q.R + 1) del(a[--nowR]);
                int mex = 1;
                while (cnt[mex] > 0) mex++;
                ans[q.id] = mex;
            }
            for (int i = 0; i < Q; i++) {
                if (ans[i] != -1) {
                    out.println(ans[i]);
                }
            }
        }

        class Query {
            int t;
            int L;
            int R;
            int id;
            int belong1;
            int belong2;

        }

    }

    static class ArrayUtil {
        public static int[] shrink(int[] a) {
            int n = a.length;
            long[] b = new long[n];
            for (int i = 0; i < n; i++) {
                b[i] = (long) a[i] << 32 | i;
            }
            Arrays.sort(b);
            int[] ret = new int[n];
            int p = 0;
            ret[0] = (int) (b[0] >> 32);
            for (int i = 0; i < n; i++) {
                if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) {
                    p++;
                    ret[p] = (int) (b[i] >> 32);
                }
                a[(int) b[i]] = p;
            }
            return Arrays.copyOf(ret, p + 1);
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream out) {
            super(out);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

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

    }
}