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 = 1e5 + 10;
inline int read() {
  char c = getchar();
  int x = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x;
}
struct Q {
  int l, r, bl, br, id, t;
  Q(){};
  Q(int l, int r, int bl, int br, int id, int t)
      : l(l), r(r), bl(bl), br(br), id(id), t(t){};
  bool operator<(const Q& rhs) const {
    if (bl != rhs.bl) return bl < rhs.bl;
    if (br != rhs.br) return br < rhs.br;
    return t < rhs.t;
  }
} q[N];
int pr[N];
struct O {
  int ix, pre, now;
  O(int ix, int pre, int now) : ix(ix), pre(pre), now(now){};
  O(){};
} oper[N];
int n, m;
int col[N], vis[N];
int ans[N];
int cnt[N * 2];
int num[N];
vector<int> ve;
void up(int x) {
  int c = col[x];
  if (vis[x]) {
    num[cnt[c]]--;
    num[--cnt[c]]++;
  } else {
    num[cnt[c]]--;
    num[++cnt[c]]++;
  }
  vis[x] ^= 1;
}
void change(int ix, int now) {
  if (vis[ix]) {
    up(ix);
    col[ix] = now;
    up(ix);
  } else
    col[ix] = now;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    pr[i] = col[i] = read();
    ve.push_back(pr[i]);
  }
  int l, r, op;
  int cnt1 = 0, cnt2 = 0;
  int Siz = (int)(pow(n, 2. / 3.));
  for (int i = 0; i < m; i++) {
    op = read(), l = read(), r = read();
    if (op == 1) {
      q[cnt1++] = Q(l, r, l / Siz, r / Siz, i, cnt2);
    } else {
      if (pr[l] == r) continue;
      oper[cnt2++] = O(l, pr[l], r);
      ve.push_back(r);
      pr[l] = r;
    }
  }
  sort(ve.begin(), ve.end());
  ve.erase(unique(ve.begin(), ve.end()), ve.end());
  for (int i = 1; i <= n; i++)
    col[i] = lower_bound(ve.begin(), ve.end(), col[i]) - ve.begin() + 1;
  for (int i = 0; i < cnt2; i++) {
    oper[i].pre =
        lower_bound(ve.begin(), ve.end(), oper[i].pre) - ve.begin() + 1;
    oper[i].now =
        lower_bound(ve.begin(), ve.end(), oper[i].now) - ve.begin() + 1;
  }
  sort(q, q + cnt1);
  memset(ans, -1, sizeof(ans));
  int L = 1, R = 1;
  up(1);
  int pt = 0;
  for (int i = 0; i < cnt1; i++) {
    while (pt < q[i].t) change(oper[pt].ix, oper[pt].now), pt++;
    while (pt > q[i].t) pt--, change(oper[pt].ix, oper[pt].pre);
    while (L > q[i].l) up(--L);
    while (L < q[i].l) up(L++);
    while (R > q[i].r) up(R--);
    while (R < q[i].r) up(++R);
    for (int j = 1;; j++) {
      if (!num[j]) {
        ans[q[i].id] = j;
        break;
      }
    }
  }
  for (int i = 0; i < m; i++)
    if (ans[i] != -1) printf("%d\n", ans[i]);
}