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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 100010, B = 2200, S = 320;
map<int, int> hm;
int n, m, cnt;
int a[N];
int m1, m2;
struct Node {
  int l, r, t, lb, rb, idx;
  bool operator<(const Node &a) const {
    return (lb != a.lb) ? (lb < a.lb)
                        : ((rb != a.rb) ? (rb < a.rb) : (t < a.t));
  }
} b[N];
int p[N], x[N];
int d[N], zc[S], c[N * 2];
inline void D_Add(int x) {
  if (!d[x]++) --zc[x / S];
  return;
}
inline void D_Dec(int x) {
  if (!--d[x]) ++zc[x / S];
  return;
}
inline void Add(int x) {
  D_Dec(c[x]);
  D_Add(++c[x]);
  return;
}
inline void Dec(int x) {
  D_Dec(c[x]);
  D_Add(--c[x]);
  return;
}
inline void Transform(int l, int r, int t) {
  if (l <= p[t] && p[t] <= r) {
    Dec(a[p[t]]);
    Add(x[t]);
  }
  swap(a[p[t]], x[t]);
  return;
}
inline int Query() {
  for (int i = 0; i <= cnt; i += S)
    if (zc[i / S]) {
      for (int j = 0; j < S; ++j)
        if (!d[i + j]) return i + j;
    }
  return -1;
}
int res[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    hm[a[i]] = 0;
  }
  for (int i = 1; i <= m; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      ++m1;
      scanf("%d%d", &b[m1].l, &b[m1].r);
      b[m1].lb = b[m1].l / B;
      b[m1].rb = b[m1].r / B;
      b[m1].t = m2;
      b[m1].idx = m1;
    } else {
      ++m2;
      scanf("%d%d", &p[m2], &x[m2]);
      hm[x[m2]] = 0;
    }
  }
  cnt = 0;
  for (map<int, int>::iterator i = hm.begin(); i != hm.end(); ++i)
    i->second = ++cnt;
  for (int i = 1; i <= n; ++i) a[i] = hm[a[i]];
  for (int i = 1; i <= m2; ++i)
    if (x[i]) x[i] = hm[x[i]];
  sort(b + 1, b + m1 + 1);
  d[0] = cnt + 1;
  for (int i = 1; i <= n; ++i) ++zc[i / S];
  int l = 1, r = 0, t = 0;
  for (int i = 1; i <= m1; ++i) {
    while (b[i].l < l) Add(a[--l]);
    while (r < b[i].r) Add(a[++r]);
    while (l < b[i].l) Dec(a[l++]);
    while (b[i].r < r) Dec(a[r--]);
    while (t < b[i].t) Transform(l, r, ++t);
    while (b[i].t < t) Transform(l, r, t--);
    res[b[i].idx] = Query();
  }
  for (int i = 1; i <= m1; ++i) printf("%d\n", res[i]);
  return 0;
}