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 n, a[300005], pos[300005], m, sum[1000005], ans[2000005], t1, t2,
    a2[2000005][2], la[2000005], a3[1000005], s1[1000005];
struct mzls {
  int l, r, id, mo;
  bool operator<(const mzls &x) const {
    if (pos[l] != pos[x.l]) return pos[l] < pos[x.l];
    if (pos[r] != pos[x.r]) return pos[r] < pos[x.r];
    return mo < x.mo;
  }
} a1[2000005];
map<int, int> mp;
int T;
int main() {
  scanf("%d%d", &n, &m);
  int d = pow(n, 2.0 / 3);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (!mp[x]) mp[x] = ++T;
    a3[i] = a[i] = mp[x];
    pos[i] = (i - 1) / d;
  }
  for (int i = 1; i <= m; i++) {
    int c1;
    scanf("%d", &c1);
    if (c1 == 1) {
      t1++;
      a1[t1].id = t1;
      scanf("%d%d", &a1[t1].l, &a1[t1].r);
      a1[t1].mo = t2;
    } else {
      t2++;
      scanf("%d%d", &a2[t2][0], &a2[t2][1]);
      if (!mp[a2[t2][1]]) mp[a2[t2][1]] = ++T;
      a2[t2][1] = mp[a2[t2][1]];
      la[t2] = a3[a2[t2][0]];
      a3[a2[t2][0]] = a2[t2][1];
    }
  }
  sort(a1 + 1, a1 + t1 + 1);
  int x = 0, l1 = 1, r1 = 0, tt = 0;
  for (int i = 1; i <= t1; i++) {
    while (r1 > a1[i].r) {
      s1[sum[a[r1]]]--;
      sum[a[r1]]--;
      s1[sum[a[r1]]]++;
      r1--;
    }
    while (r1 < a1[i].r) {
      r1++;
      s1[sum[a[r1]]]--;
      sum[a[r1]]++;
      s1[sum[a[r1]]]++;
    }
    while (l1 > a1[i].l) {
      l1--;
      s1[sum[a[l1]]]--;
      sum[a[l1]]++;
      s1[sum[a[l1]]]++;
    }
    while (l1 < a1[i].l) {
      s1[sum[a[l1]]]--;
      sum[a[l1]]--;
      s1[sum[a[l1]]]++;
      l1++;
    }
    while (tt < a1[i].mo) {
      tt++;
      if (a2[tt][0] >= l1 && a2[tt][0] <= r1) {
        s1[sum[a2[tt][1]]]--;
        sum[a2[tt][1]]++;
        s1[sum[a2[tt][1]]]++;
        s1[sum[a[a2[tt][0]]]]--;
        sum[a[a2[tt][0]]]--;
        s1[sum[a[a2[tt][0]]]]++;
      }
      a[a2[tt][0]] = a2[tt][1];
    }
    while (tt > a1[i].mo) {
      if (a2[tt][0] >= l1 && a2[tt][0] <= r1) {
        s1[sum[a2[tt][1]]]--;
        sum[a2[tt][1]]--;
        s1[sum[a2[tt][1]]]++;
        s1[sum[la[tt]]]--;
        sum[la[tt]]++;
        s1[sum[la[tt]]]++;
      }
      a[a2[tt][0]] = la[tt];
      tt--;
    }
    for (x = 1;; x++)
      if (!s1[x]) break;
    ans[a1[i].id] = x;
  }
  for (int i = 1; i <= t1; i++) printf("%d\n", ans[i]);
}