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 + 7;
int cnt[maxn * 2];
int a[maxn];
int n;
int q;
int pos[maxn];
int block = 2000;
int cntcnt[maxn];
int b[maxn * 2];
int ans[maxn];
struct node {
  int l, r;
  int md;
  int id;
  int ans;
  bool operator<(const node &p) const {
    if (pos[this->l] == pos[p.l]) {
      if (pos[this->r] == pos[p.r]) {
        return this->md < p.md;
      }
      return this->r < p.r;
    }
    return pos[this->l] < pos[p.l];
  }
} Q[maxn];
struct node2 {
  int p;
  int to;
  int pre;
} modity[maxn];
void add(int va) {
  cntcnt[cnt[va]]--;
  cnt[va]++;
  cntcnt[cnt[va]]++;
}
void del(int va) {
  cntcnt[cnt[va]]--;
  cnt[va]--;
  cntcnt[cnt[va]]++;
}
int L, R;
void mf(node2 &the) {
  if (the.p >= L && the.p <= R) {
    del(the.pre);
    add(the.to);
  }
  a[the.p] = the.to;
}
void mb(node2 &the) {
  if (the.p >= L && the.p <= R) {
    del(the.to);
    add(the.pre);
  }
  a[the.p] = the.pre;
}
void getpos() {
  for (int i = 1; i <= n; i++) {
    pos[i] = i / block;
  }
}
int main() {
  cntcnt[0] = 1e8;
  int p = 0;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    b[p++] = a[i];
  }
  block = max((int)pow(n, 2 * 1.0 / 3), 1);
  getpos();
  int now = 0;
  int q1 = 0;
  int q2 = 1;
  for (int i = 0; i < q; i++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d", &Q[q1].l, &Q[q1].r);
      Q[q1].ans = 1;
      Q[q1].md = now;
      Q[q1].id = q1;
      q1++;
    } else {
      int pp;
      int va;
      scanf("%d%d", &pp, &va);
      now++;
      modity[q2].p = pp;
      modity[q2].pre = a[pp];
      modity[q2++].to = va;
      a[pp] = va;
      b[p++] = va;
    }
  }
  sort(b, b + p);
  sort(Q, Q + q1);
  int sz = unique(b, b + p) - b;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(b, b + sz, a[i]) - b;
  }
  for (int i = 1; i <= q2; i++) {
    modity[i].pre = lower_bound(b, b + sz, modity[i].pre) - b;
    modity[i].to = lower_bound(b, b + sz, modity[i].to) - b;
  }
  int curt = now;
  R = 0;
  L = 1;
  for (int i = 0; i < q1; i++) {
    while (R < Q[i].r) add(a[++R]);
    while (L < Q[i].l) del(a[L++]);
    while (R > Q[i].r) del(a[R--]);
    while (L > Q[i].l) add(a[--L]);
    while (curt < Q[i].md) mf(modity[++curt]);
    while (curt > Q[i].md) mb(modity[curt--]);
    while (cntcnt[Q[i].ans] > 0) Q[i].ans++;
    ans[Q[i].id] = Q[i].ans;
  }
  for (int i = 0; i < q1; i++) {
    printf("%d\n", ans[i]);
  }
}