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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * f;
}
const int maxn = 5e5 + 10;
int n, m, blo, a[maxn], S[maxn], tot, bl[maxn], l = 1, r = 0, t, tot1, tot2,
                                                ans[maxn], cnt[maxn], mex[maxn];
struct node {
  int l, r, t, id;
} q[maxn];
struct upt {
  int pos, x;
} c[maxn];
bool cmp(node a, node b) {
  return (bl[a.l] ^ bl[b.l])
             ? bl[a.l] < bl[b.l]
             : ((bl[a.r] ^ bl[b.r]) ? bl[a.r] < bl[b.r] : a.t < b.t);
}
void add(int x) {
  --mex[cnt[x]];
  ++mex[++cnt[x]];
}
void del(int x) {
  --mex[cnt[x]];
  ++mex[--cnt[x]];
}
void update(int id, int time) {
  if (c[time].pos >= q[id].l && c[time].pos <= q[id].r) {
    del(a[c[time].pos]), add(c[time].x);
  }
  swap(a[c[time].pos], c[time].x);
}
int main() {
  n = read(), m = read();
  blo = pow(n, 0.66666);
  blo = 3000;
  for (int i = 1; i <= n; ++i)
    a[i] = read(), S[++tot] = a[i], bl[i] = (i - 1) / blo + 1;
  for (int i = 1; i <= m; ++i) {
    int opt, x, y;
    opt = read(), x = read(), y = read();
    if (opt == 1) {
      q[++tot2].l = x;
      q[tot2].r = y;
      q[tot2].id = tot2;
      q[tot2].t = tot1;
    }
    if (opt == 2) {
      c[++tot1].pos = x;
      c[tot1].x = y;
      S[++tot] = y;
    }
  }
  sort(S + 1, S + tot + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(S + 1, S + tot + 1, a[i]) - S;
  }
  for (int i = 1; i <= tot1; ++i) {
    c[i].x = lower_bound(S + 1, S + tot + 1, c[i].x) - S;
  }
  sort(q + 1, q + tot2 + 1, cmp);
  for (int i = 1; i <= tot2; ++i) {
    while (l < q[i].l) del(a[l++]);
    while (l > q[i].l) add(a[--l]);
    while (r < q[i].r) add(a[++r]);
    while (r > q[i].r) del(a[r--]);
    while (t < q[i].t) update(i, ++t);
    while (t > q[i].t) update(i, t--);
    for (ans[q[i].id] = 1; mex[ans[q[i].id]] > 0; ++ans[q[i].id])
      ;
  }
  for (int i = 1; i <= tot2; ++i) {
    printf("%d\n", ans[i]);
  }
}