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(2)
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
long long n, m, blk;
long long a[200005], t[200005], len;
long long qn, cn;
struct node {
  long long l, r, t, id;
  bool operator<(const node& b) const {
    if (l / blk != b.l / blk) return l < b.l;
    if (r / blk != b.r / blk) return r < b.r;
    return t < b.t;
  }
} q[200005];
struct mdf {
  long long p, v;
} c[200005];
long long ct[200005], cnt[200005];
inline void add(long long v) {
  ct[cnt[v]]--;
  ct[++cnt[v]]++;
}
inline void del(long long v) {
  ct[cnt[v]]--;
  ct[--cnt[v]]++;
}
long long res[200005];
signed main() {
  n = read(), m = read();
  len = n;
  for (register long long i = (1); i <= (n); ++i) a[i] = t[i] = read();
  blk = pow(n, 0.666666);
  for (register long long i = (1); i <= (m); ++i) {
    long long op = read();
    if (op == 1)
      q[++qn] = (node){read(), read(), cn, qn};
    else
      c[++cn] = (mdf){read(), read()}, t[++len] = c[cn].v;
  }
  sort(t + 1, t + len + 1);
  len = unique(t + 1, t + len + 1) - t - 1;
  for (register long long i = (1); i <= (n); ++i)
    a[i] = lower_bound(t + 1, t + len + 1, a[i]) - t;
  for (register long long i = (1); i <= (cn); ++i)
    c[i].v = lower_bound(t + 1, t + len + 1, c[i].v) - t;
  sort(q + 1, q + qn + 1);
  long long l = 1, r = 0, t = 0;
  for (register long long i = (1); i <= (qn); ++i) {
    long long ql = q[i].l, qr = q[i].r, qt = q[i].t;
    while (r < qr) add(a[++r]);
    while (l > ql) add(a[--l]);
    while (r > qr) del(a[r--]);
    while (l < ql) del(a[l++]);
    while (t < qt) {
      t++;
      if (ql <= c[t].p && c[t].p <= qr) add(c[t].v), del(a[c[t].p]);
      swap(c[t].v, a[c[t].p]);
    }
    while (t > qt) {
      if (ql <= c[t].p && c[t].p <= qr) add(c[t].v), del(a[c[t].p]);
      swap(c[t].v, a[c[t].p]);
      t--;
    }
    res[q[i].id] = 1;
    while (ct[res[q[i].id]]) res[q[i].id]++;
  }
  for (register long long i = (1); i <= (qn); ++i) cout << res[i] << endl;
  return 0;
}