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 read() {
  int r = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) r = (r << 1) + (r << 3) + (c ^ 48), c = getchar();
  return r;
}
inline int min(int a, int b) { return a < b ? a : b; }
inline void swap(int &a, int &b) {
  int c = a;
  a = b;
  b = c;
}
int n, m, t, l, r, size, a[101101], lb[101101], rb[101101], pos[101101],
    cnt_cnt[101101], tot[101101], ans[101101];
int s_lsh, lsh[101101 << 1], cnt[101101 << 1];
int b[101101][2];
struct Q {
  int l, r, t, num;
  bool operator<(const Q &q) const {
    return pos[l] ^ pos[q.l] ? pos[l] < pos[q.l]
           : pos[r] ^ pos[q.r]
               ? pos[l] & 1 ? pos[r] < pos[q.r] : pos[r] > pos[q.r]
           : pos[r] & 1 ? t < q.t
                        : t > q.t;
  }
} q[101101];
inline void change(int x, int val) {
  tot[pos[cnt[a[x]]]] -= (cnt_cnt[cnt[a[x]]] == 1);
  cnt_cnt[cnt[a[x]]]--;
  cnt[a[x]] += val;
  cnt_cnt[cnt[a[x]]]++;
  tot[pos[cnt[a[x]]]] += (cnt_cnt[cnt[a[x]]] == 1);
}
inline void modify(int x) {
  if (b[x][0] >= l && b[x][0] <= r) {
    change(b[x][0], -1);
    swap(a[b[x][0]], b[x][1]);
    change(b[x][0], 1);
  } else
    swap(a[b[x][0]], b[x][1]);
}
inline int query() {
  for (int i = 1; i <= pos[n]; i++) {
    if (tot[i] == rb[i] - lb[i] + 1) continue;
    for (int j = lb[i]; j <= rb[i]; j++)
      if (!cnt_cnt[j]) return j;
  }
  return n + 1;
}
inline int find(int x) {
  int l = 0, r = s_lsh + 1;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (lsh[mid] <= x)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  n = read(), m = read();
  s_lsh = n;
  size = pow(n, 0.67);
  for (int i = 1; i <= n; i++) {
    pos[i] = (i - 1) / size + 1;
    a[i] = lsh[i] = read();
  }
  for (int i = 1; i <= pos[n]; i++) {
    lb[i] = (i - 1) * size + 1;
    rb[i] = min(lb[i] + size - 1, n);
  }
  for (int i = 1; i <= m; i++) {
    int opt = read();
    if (opt & 1) {
      q[i - t].l = read(), q[i - t].r = read(), q[i - t].t = t;
      q[i - t].num = i - t;
    } else
      b[++t][0] = read(), lsh[++s_lsh] = b[t][1] = read();
  }
  sort(lsh + 1, lsh + 1 + s_lsh);
  for (int i = 2; i <= s_lsh; i++)
    if (lsh[i] == lsh[i - 1]) lsh[i - 1] = 1e9 + 10;
  sort(lsh + 1, lsh + 1 + s_lsh);
  for (int i = 1; i <= n; i++) a[i] = find(a[i]);
  for (int i = 1; i <= t; i++) b[i][1] = find(b[i][1]);
  m -= t;
  sort(q + 1, q + m + 1);
  cnt[0] = n;
  l = q[1].l, r = q[1].l - 1, t = 0;
  for (int i = 1; i <= m; i++) {
    while (l > q[i].l) change(--l, 1);
    while (r < q[i].r) change(++r, 1);
    while (l < q[i].l) change(l++, -1);
    while (r > q[i].r) change(r--, -1);
    while (t < q[i].t) modify(++t);
    while (t > q[i].t) modify(t--);
    ans[q[i].num] = query();
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}