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.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author chaku
 */
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);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), Q = in.nextInt();
            int[] a = in.nextIntArray(n);

            int[][] qs = new int[Q][];
            for (int i = 0; i < Q; i++) {
                int t = in.nextInt();
                if (t == 1) {
                    qs[i] = new int[]{1, in.nextInt() - 1, in.nextInt() - 1, i, -1};
                } else {
                    qs[i] = new int[]{2, in.nextInt() - 1, in.nextInt(), -1};
                }
            }
            int[] vs = Arrays.copyOf(a, n + Q);
            for (int i = 0; i < Q; i++) {
                if (qs[i][0] == 2) vs[n + i] = qs[i][2];
            }
            vs = shrink(vs);
            for (int i = 0; i < Q; i++) {
                if (qs[i][0] == 2) qs[i][2] = vs[n + i];
            }
            for (int i = 0; i < n; i++) {
                a[i] = vs[i];
            }

            int[] b = Arrays.copyOf(a, n);
            for (int i = 0; i < Q; i++) {
                if (qs[i][0] == 2) {
                    qs[i][3] = b[qs[i][1]];
                    b[qs[i][1]] = qs[i][2];
                }
            }

            int[][] qos = new int[Q][];
            int p = 0;
            for (int[] q : qs) {
                if (q[0] == 1) qos[p++] = q;
            }
            qos = Arrays.copyOf(qos, p);

//		int B = (int)Math.sqrt(n);
            int B = (int) Math.pow(2 * n - 1, 2. / 3);
            Arrays.sort(qos, new Comparator<int[]>() {
                public int compare(int[] a, int[] b) {
                    if (a[3] / B != b[3] / B) return a[3] - b[3];
                    if (a[1] / B != b[1] / B) return a[1] - b[1];
                    return a[1] / B % 2 == 0 ? a[2] - b[2] : b[2] - a[2];
                }
            });

            TaskF.Freqs f = new TaskF.Freqs(n + Q + 3);
            int L = 0, R = -1, T = -1;
            for (int[] q : qos) {
                while (T < q[3]) {
                    int[] tar = qs[++T];
                    if (tar[0] == 2) {
                        if (L <= tar[1] && tar[1] <= R) {
                            f.dec(tar[3]);
                            f.inc(tar[2]);
                        }
                        a[tar[1]] = tar[2];
                    }
                }
                while (T > q[3]) {
                    int[] tar = qs[T--];
                    if (tar[0] == 2) {
                        if (L <= tar[1] && tar[1] <= R) {
                            f.dec(tar[2]);
                            f.inc(tar[3]);
                        }
                        a[tar[1]] = tar[3];
                    }
                }
                while (R < q[2]) f.inc(a[++R]);
                while (L > q[1]) f.inc(a[--L]);
                while (R > q[2]) f.dec(a[R--]);
                while (L < q[1]) f.dec(a[L++]);

                q[4] = f.mex();
            }
            for (int[] q : qs) {
                if (q[0] == 1) {
                    out.println(q[4]);
                }
            }

        }

        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;
            radixsort(b, n);
            int[] ret = new int[n];
            int p = 0;
            for (int i = 0; i < n; i++) {
                if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0)
                    p++;
                ret[(int) b[i]] = p;
            }
            return ret;
        }

        static long getMax(long arr[], int n) {
            long mx = arr[0];
            for (int i = 1; i < n; i++)
                if (arr[i] > mx)
                    mx = arr[i];
            return mx;
        }

        static void countSort(long arr[], int n, long exp) {
            long[] output = new long[n]; // output array
            int i;
            int count[] = new int[10];
            Arrays.fill(count, 0);

            // Store count of occurrences in count[]
            for (i = 0; i < n; i++)
                count[(int) ((arr[i] / exp) % 10)]++;

            // Change count[i] so that count[i] now contains
            // actual position of this digit in output[]
            for (i = 1; i < 10; i++)
                count[i] += count[i - 1];

            // Build the output array
            for (i = n - 1; i >= 0; i--) {
                output[count[(int) ((arr[i] / exp) % 10)] - 1] = arr[i];
                count[(int) ((arr[i] / exp) % 10)]--;
            }

            // Copy the output array to arr[], so that arr[] now
            // contains sorted numbers according to curent digit
            for (i = 0; i < n; i++)
                arr[i] = output[i];
        }

        static void radixsort(long arr[], int n) {
            // Find the maximum number to know number of digits
            long m = getMax(arr, n);

            // Do counting sort for every digit. Note that instead
            // of passing digit number, exp is passed. exp is 10^i
            // where i is current digit number
            for (long exp = 1; m / exp > 0; exp *= 10)
                countSort(arr, n, exp);

            //return arr;
        }

        public static class Freqs {
            public int[] f;
            public int[] ff;
            public int max;

            public Freqs(int n) {
                f = new int[n];
                ff = new int[n + 1];
                ff[0] = n;
                max = 0;
            }

            int mex() {
                for (int i = 0; ; i++) {
                    if (ff[i] == 0) return i;
                }
            }

            public void inc(int x) {
                if (x < 0 || x >= ff.length) throw new RuntimeException();
                ff[f[x]]--;
                ff[f[x] + 1]++;
                if (max == f[x]) max = f[x] + 1;
                f[x]++;
            }

            public void dec(int x) {
                if (x < 0 || x >= ff.length) throw new RuntimeException();
                if (f[x] == 0) throw new RuntimeException();
                ff[f[x]]--;
                ff[f[x] - 1]++;
                if (max == f[x] && ff[f[x]] == 0) max = f[x] - 1;
                f[x]--;
            }

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

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

        public void println(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

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

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

        }

    }
}