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 MAXN = 1e5 + 10;
int l = 1, r = 0;
int a[MAXN], b[MAXN], now[MAXN], num[MAXN << 1], cnt[MAXN], ans[MAXN];
map<int, int> ms;
struct Change {
  int p, x, y;
} c[MAXN];
struct Query {
  int l, r, t, id;
  bool operator<(const Query &A) const {
    if (b[l] == b[A.l]) return b[r] == b[A.r] ? t < A.t : b[r] < b[A.r];
    return b[l] < b[A.l];
  }
} q[MAXN];
void update(int x, int d) {
  int &y = num[x];
  if (y > 0) cnt[y]--;
  y += d;
  if (y > 0) cnt[y]++;
}
void modify(int p, int d) {
  if (l <= p && p <= r) {
    update(a[p], -1);
    update(d, 1);
  }
  a[p] = d;
}
int get() {
  for (int i = 1;; i++) {
    if (!cnt[i]) return i;
  }
}
int main() {
  int n, m, id = 0, Time = 0, sz = 0;
  scanf("%d%d", &n, &m);
  int B = 2000;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int &t = ms[a[i]];
    if (!t) t = ++sz;
    now[i] = a[i] = t;
    b[i] = i / B + 1;
  }
  while (m--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      q[++id] = (Query){x, y, Time, id};
    else {
      int &t = ms[y];
      if (!t) t = ++sz;
      c[++Time] = (Change){x, y = t, now[x]};
      now[x] = y;
    }
  }
  sort(q + 1, q + id + 1);
  int v = 0;
  for (int i = 1; i <= id; i++) {
    while (v < q[i].t) modify(c[v + 1].p, c[v + 1].x), v++;
    while (v > q[i].t) modify(c[v].p, c[v].y), v--;
    while (l < q[i].l) update(a[l], -1), l++;
    while (l > q[i].l) update(a[l - 1], 1), l--;
    while (r < q[i].r) update(a[r + 1], 1), r++;
    while (r > q[i].r) update(a[r], -1), r--;
    ans[q[i].id] = get();
  }
  for (int i = 1; i <= id; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}