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;
int Add(int &a, int b) { a = (a + b) % 1000000007; }
int Min(int &a, int b) { a = (a + 1000000007 - b) % 1000000007; }
int Mul(int &a, int b) { a = (long long)a * b % 1000000007; }
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long pow(long long a, long long b) {
  long long res(1);
  while (b) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
long long powM(long long a, long long b, long long mod) {
  long long res(1);
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
const int infi = 2147483647;
const long long infl = 9223372036854775807;
int bel[100010];
struct Query {
  int l, r, t, i;
  bool operator<(const Query &x) const {
    if (bel[l] == bel[x.l]) {
      if (bel[r] == bel[x.r]) return t < x.t;
      return bel[r] < bel[x.r];
    }
    return bel[l] < bel[x.l];
  }
} qu[100010];
struct Upd {
  int p, x, x0;
} upd[100010];
map<int, int> s;
int cnt, a[100010], ans[100010];
int unique(int x) {
  if (s.find(x) == s.end()) {
    return s[x] = ++cnt;
  }
  return s[x];
}
int n, m, k, T;
int cnt1[100010 << 1], cnt2[100010];
void ins(int x) {
  --cnt2[cnt1[x]];
  ++cnt2[++cnt1[x]];
}
void dec(int x) {
  if (!cnt1[x]) return;
  --cnt2[cnt1[x]];
  ++cnt2[--cnt1[x]];
}
int b[100010];
int cnt3[100010], cnt4[100010];
int main() {
  scanf("%d", &n), scanf("%d", &m);
  k = pow(n, 2.0 / 3.0);
  for (int i = 1; i <= (n); ++i)
    bel[i] = (i - 1) / (k) + 1, scanf("%d", &a[i]), a[i] = unique(a[i]);
  for (int i = 1; i <= (n); ++i) b[i] = a[i];
  int t1 = 0, t2 = 0;
  for (int i = 1; i <= (m); ++i) {
    scanf("%d", &T);
    if (T == 1) {
      t1++;
      int l, r;
      scanf("%d", &l), scanf("%d", &r);
      if (l > r) swap(l, r);
      qu[t1] = (Query){l, r, t2, t1};
    } else {
      t2++;
      int p, x;
      scanf("%d", &p), scanf("%d", &x);
      x = unique(x);
      upd[t2] = (Upd){p, x, a[p]};
      a[p] = x;
    }
  }
  sort(qu + 1, qu + 1 + t1);
  for (int i = (t2); i > 0; --i) a[upd[i].p] = upd[i].x0;
  for (int i = 1; i <= (n); ++i)
    if (a[i] != b[i]) {
      puts("hh");
    }
  int l = 1, r = 1, t = 0;
  ins(a[l]);
  cnt2[0] = 1e9;
  int c;
  for (int i = 1; i <= (t1); ++i) {
    while (t + 1 <= qu[i].t) {
      t++;
      if (l <= upd[t].p && upd[t].p <= r) {
        dec(upd[t].x0);
        ins(upd[t].x);
      }
      a[upd[t].p] = upd[t].x;
    }
    while (t > qu[i].t) {
      if (l <= upd[t].p && upd[t].p <= r) {
        dec(upd[t].x);
        ins(upd[t].x0);
      }
      a[upd[t].p] = upd[t].x0;
      t--;
    }
    while (r < qu[i].r) {
      ins(a[++r]);
    }
    while (l < qu[i].l) {
      dec(a[l++]);
    }
    while (l > qu[i].l) {
      ins(a[--l]);
    }
    while (r > qu[i].r) {
      dec(a[r--]);
    }
    c = 1;
    while (cnt2[c]) c++;
    ans[qu[i].i] = c;
  }
  for (int i = 1; i <= (t1); ++i) printf("%d", (ans[i])), putchar('\n');
  return 0;
}