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 void read() {}
template <typename T, typename... Ts>
inline void read(T& A, Ts&... As) {
  T x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  A = x * f, read(As...);
}
inline void write(char a) { putchar(a); }
template <typename T>
inline void write(T a) {
  if (a < 0ll) putchar('-'), a = -a;
  if (a > 9ll) write(a / 10ll);
  putchar(a % 10ll + '0');
}
template <typename T, typename... Ts>
inline void write(T A, Ts... As) {
  write(A), write(As...);
}
const int N = 200010, B = 2510;
int n, m, a[N], b[N], s[N], v;
pair<int, int> mdf[N];
int pos[N];
struct node {
  int opt, l, r, t;
  inline void init(int x) {
    read(opt, l, r), t = x;
    if (opt == 2) s[++v] = r;
  }
  inline void upd() {
    if (opt == 2) {
      r = lower_bound(s + 1, s + v + 1, r) - s;
      mdf[t] = pair<int, int>(b[pos[t] = l], r), b[l] = r;
    }
  }
} q[N];
int w[N], c[N], ans[N];
int l = 1, r, t;
inline void upd(int x, int v) { --w[c[x]], ++w[c[x] += v]; }
inline void add(int k, int v) {
  int x = mdf[k].first, y = mdf[k].second;
  if (pos[k] >= l && pos[k] <= r) upd(x, -v), upd(y, v);
  a[pos[k]] = (~v ? y : x);
}
inline int qmex() {
  for (register int i = 1;; ++i)
    if (!w[i]) return i;
}
signed main() {
  read(n, m), v = n;
  for (register int i = 1; i <= n; ++i) read(a[i]), s[i] = a[i];
  for (register int i = 1; i <= m; ++i) q[i].init(i);
  sort(s + 1, s + v + 1), v = unique(s + 1, s + v + 1) - s - 1;
  for (register int i = 1; i <= n; ++i)
    b[i] = a[i] = lower_bound(s + 1, s + v + 1, a[i]) - s;
  for (register int i = 1; i <= m; ++i) q[i].upd();
  sort(q + 1, q + m + 1, [&](node x, node y) {
    return x.l / B == y.l / B ? (x.r / B == y.r / B ? x.t < y.t : x.r < y.r)
                              : x.l < y.l;
  });
  for (register int i = 1; i <= m; ++i) {
    if (q[i].opt == 2) continue;
    while (l > q[i].l) upd(a[--l], 1);
    while (r < q[i].r) upd(a[++r], 1);
    while (l < q[i].l) upd(a[l++], -1);
    while (r > q[i].r) upd(a[r--], -1);
    while (t > q[i].t) add(t--, -1);
    while (t < q[i].t) add(++t, 1);
    ans[q[i].t] = qmex();
  }
  for (register int i = 1; i <= m; ++i)
    if (ans[i]) write(ans[i], '\n');
  return 0;
}