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;
int blo[200000], bb, fuc[200000], L[200000], R[200000], T[200000], a[200000],
    b[200000], sz, kuai, nowl, nowr, nowx, cnt[200000], cntt[200000];
struct ooxx {
  int l, r, x, id, ans;
} md[200000];
struct xxoo {
  int o, p;
} xg[300000];
bool comp(ooxx em, ooxx emm) {
  if (blo[em.l] != blo[emm.l]) return blo[em.l] < blo[emm.l];
  if (blo[em.r] != blo[emm.r]) return blo[em.r] < blo[emm.r];
  return em.x < emm.x;
}
bool cmp(ooxx em, ooxx emm) { return em.id < emm.id; }
int find(int x) {
  int l = 1, r = sz, mid;
  while (1) {
    mid = (l + r) >> 1;
    if (l == r) return mid;
    if (b[mid] >= x)
      r = mid;
    else
      l = mid + 1;
  }
}
inline void D(int &l, int &r) { r++, cntt[cnt[a[r]]]--, cntt[++cnt[a[r]]]++; }
inline void S(int &l, int &r) { l--, cntt[cnt[a[l]]]--, cntt[++cnt[a[l]]]++; }
inline void A(int &l, int &r) { cntt[cnt[a[r]]]--, cntt[--cnt[a[r]]]++, r--; }
inline void W(int &l, int &r) { cntt[cnt[a[l]]]--, cntt[--cnt[a[l]]]++, l++; }
inline void change(int x) {
  if (nowr >= xg[x].o && xg[x].o >= nowl)
    cntt[cnt[a[xg[x].o]]]--, cntt[--cnt[a[xg[x].o]]]++, cntt[cnt[xg[x].p]]--,
        cntt[++cnt[xg[x].p]]++;
  a[xg[x].o] = xg[x].p;
}
inline int query() {
  for (int i = 1; i <= 10000; ++i)
    if (!cntt[i]) return i;
}
int main() {
  int n, q;
  bb = 2000;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), b[i] = a[i], blo[i] = (i - 1) / bb + 1;
  int ct = n, hhh = 0;
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d%d", &T[i], &L[i], &R[i]);
    if (T[i] == 2) b[++ct] = R[i], ++hhh;
  }
  sort(b + 1, b + ct + 1);
  sz = unique(b + 1, b + ct + 1) - (b + 1);
  for (int i = 1; i <= n; ++i) a[i] = find(a[i]), fuc[i] = a[i];
  int js = 0, hh = 0;
  for (register int i = 1; i <= q; ++i) {
    if (T[i] == 2)
      xg[++js].o = L[i], xg[js].p = find(R[i]), xg[hhh + js].o = L[i],
      xg[hhh + js].p = fuc[xg[js].o], fuc[xg[js].o] = xg[js].p;
    else
      md[++hh].x = js, md[hh].l = L[i], md[hh].r = R[i], md[hh].id = i;
  }
  sort(md + 1, md + 1 + hh, comp);
  nowl = nowr = 1, cnt[a[1]] = 1, cntt[1] = 1, nowx = 0;
  for (int i = 1; i <= hh; ++i) {
    if (md[i].l == md[i].r) {
      md[i].ans = 2;
      continue;
    }
    while (nowr < md[i].r) D(nowl, nowr);
    while (nowl > md[i].l) S(nowl, nowr);
    while (nowr > md[i].r) A(nowl, nowr);
    while (nowl < md[i].l) W(nowl, nowr);
    while (nowx < md[i].x) change(++nowx);
    while (nowx > md[i].x) change(js + nowx--);
    md[i].ans = query();
  }
  sort(md + 1, md + 1 + hh, cmp);
  for (int i = 1; i <= hh; ++i) {
    printf("%d\n", md[i].ans);
  }
  return 0;
}