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;
inline int rd() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x;
}
int n, m, B, opt, x, y, t1, t2, tot, len, _;
int a[100005 << 1], id[100005], ct[100005 << 1], cnt[100005], ans[100005];
struct T {
  int i, x;
  bool operator<(const T &b) const { return x < b.x; }
} t[100005 << 1];
struct Q {
  int l, r, i, t;
  bool operator<(const Q &b) const {
    return id[l] ^ id[b.l] ? l < b.l : id[r] ^ id[b.r] ? r < b.r : t < b.t;
  }
} q[100005];
struct C {
  int i, x;
} c[100005];
inline void init() {
  sort(t + 1, t + 1 + len);
  for (int i = 1; i <= len; ++i) {
    if (t[i].x ^ t[i - 1].x) ++tot;
    if (t[i].i > n) {
      c[t[i].i - n].x = tot;
    } else {
      a[t[i].i] = tot;
    }
  }
}
inline void add(int x) { --cnt[ct[x]], ++cnt[++ct[x]]; }
inline void del(int x) { --cnt[ct[x]], ++cnt[--ct[x]]; }
inline void work(int t, int i) {
  if (q[i].l <= c[t].i && c[t].i <= q[i].r) {
    del(a[c[t].i]), add(c[t].x);
  }
  (_ = a[c[t].i], a[c[t].i] = c[t].x, c[t].x = _);
}
inline int query(int i = 1) {
  while (cnt[i]) ++i;
  return i;
}
inline void Mo() {
  int l = 1, r = 0, t = 0;
  sort(q + 1, q + 1 + t1);
  for (int i = 1; i <= t1; ++i) {
    const int &L = q[i].l, &R = q[i].r;
    while (l > L) add(a[--l]);
    while (r < R) add(a[++r]);
    while (l < L) del(a[l++]);
    while (r > R) del(a[r--]);
    while (t < q[i].t) work(++t, i);
    while (t > q[i].t) work(t--, i);
    ans[q[i].i] = query();
  }
}
int main() {
  n = rd(), m = rd();
  B = pow(n, 2.0 / 3);
  for (int i = 1; i <= n; ++i) {
    t[i] = (T){i, rd()};
    id[i] = i / B;
  }
  len = n;
  while (m--) {
    opt = rd(), x = rd(), y = rd();
    if (opt & 1) {
      ++t1, q[t1] = (Q){x, y, t1, t2};
    } else {
      c[++t2] = (C){x, y};
      t[++len] = (T){t2 + n, y};
    }
  }
  init(), Mo();
  for (int i = 1; i <= t1; ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}