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 B, a[1000007], anw[1000007], ans, opt, pl, pr, Now_ti, n, m;
int ot, cnt, l, r;
int usd[1000007], ch;
int b[1000007];
template <class T>
inline void read(T &x) {
  static char c;
  static int b;
  for (b = 1, c = getchar(); !('0' <= c && c <= '9'); c = getchar())
    if (c == '-') b = -1;
  for (x = 0; ('0' <= c && c <= '9'); c = getchar()) x = x * 10 + c - 48;
  x *= b;
}
struct Node {
  int l, r, id, tim;
  inline bool operator<(const Node &A) const {
    if (((l - 1) / B + 1) ^ ((A.l - 1) / B + 1)) return l < A.l;
    if (((r - 1) / B + 1) ^ ((A.r - 1) / B + 1)) return r < A.r;
    return id < A.id;
  }
} g[1000007];
struct cha {
  int p, col, fre;
} p[1000007];
int pp, c[1000007], gg, usdd[1000007];
inline void add(int x) {
  pp = usdd[a[x]]++;
  if (pp < 1000007) usd[pp]--;
  if (pp + 1 < 1000007) usd[pp + 1]++;
}
inline void del(int x) {
  pp = usdd[a[x]]--;
  if (pp < 1000007) usd[pp]--;
  if (pp - 1 < 1000007) usd[pp - 1]++;
}
inline void change_add(int Tim) {
  opt = p[Tim].p;
  if (opt <= pr && pl <= opt) {
    del(opt);
    a[opt] = p[Tim].col;
    add(opt);
  }
  a[opt] = p[Tim].col;
}
inline void change_del(int Tim) {
  opt = p[Tim].p;
  if (opt <= pr && pl <= opt) {
    del(opt);
    a[opt] = p[Tim].fre;
    add(opt);
  }
  a[opt] = p[Tim].fre;
}
inline void change(int Tim) {
  while (Now_ti < Tim) change_add(++Now_ti);
  while (Now_ti > Tim) change_del(Now_ti--);
}
int dos() {
  for (int i = 1;; i++)
    if (!usd[i]) return i;
}
int main() {
  scanf("%d%d", &n, &m);
  B = (int)pow(n, 0.667);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i], c[i] = a[i];
  gg = n;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &ch);
    if (ch & 1) {
      ++ot;
      scanf("%d%d", &g[ot].l, &g[ot].r);
      g[ot].id = ot;
      g[ot].tim = cnt;
    } else {
      cnt++;
      scanf("%d%d", &p[cnt].p, &p[cnt].col);
      c[++gg] = p[cnt].col;
      p[cnt].fre = b[p[cnt].p];
      b[p[cnt].p] = p[cnt].col;
    }
  }
  sort(c + 1, c + gg + 1);
  for (int i = 1; i <= n; i++) a[i] = lower_bound(c + 1, c + gg, a[i]) - c;
  for (int i = 1; i <= cnt; i++)
    p[i].fre = lower_bound(c + 1, c + gg, p[i].fre) - c,
    p[i].col = lower_bound(c + 1, c + gg, p[i].col) - c;
  sort(g + 1, g + ot + 1);
  for (int i = 1; i <= ot; i++) {
    change(g[i].tim);
    while (pl > g[i].l) add(--pl);
    while (pr < g[i].r) add(++pr);
    while (pl < g[i].l) del(pl++);
    while (pr > g[i].r) del(pr--);
    anw[g[i].id] = dos();
  }
  for (int i = 1; i <= ot; i++) printf("%d\n", anw[i]);
  return 0;
}