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;
vector<pair<int, int> > upd;
struct query {
  int l, r, t, id, ans;
  query() {}
  query(int _l, int _r, int _t, int _id) {
    l = _l;
    r = _r;
    t = _t;
    id = _id;
  }
};
vector<query> que;
stack<pair<int, int> > S;
vector<int> V;
int M[1005][105];
int sz[1005];
int cnt[300005];
int data[100005];
int B;
int l = 1, r = 0, t = 0, Ans = 1;
int cmp(query a, query b) {
  if (a.l / B != b.l / B) return a.l < b.l;
  if (a.r / B != b.r / B) return a.r < b.r;
  return a.t < b.t;
}
int cmpid(query a, query b) { return a.id < b.id; }
int Upd() {
  for (int i = (Ans / 100); i < (1000); i++)
    if (sz[i] < 100) {
      for (int j = (0); j < (100); j++)
        if (!M[i][j]) {
          return i * 100 + j;
        }
    }
}
void Add(int a) {
  if (!M[a / 100][a % 100]) sz[a / 100]++;
  M[a / 100][a % 100]++;
  if (Ans == a) Ans = Upd();
}
void Del(int a) {
  M[a / 100][a % 100]--;
  if (!M[a / 100][a % 100]) {
    sz[a / 100]--;
    if (Ans > a) Ans = a;
  }
}
void add(int a) {
  Del(cnt[a]);
  Add(++cnt[a]);
}
void del(int a) {
  Del(cnt[a]);
  Add(--cnt[a]);
}
int main() {
  M[0][0] = 1e9;
  int n, m;
  scanf("%d%d", &n, &m);
  B = pow(n, 2.0 / 3);
  for (int i = (1); i < (n + 1); i++)
    scanf("%d", &data[i]), V.push_back(data[i]);
  while (m--) {
    int co, a, b;
    scanf("%d%d%d", &co, &a, &b);
    if (co == 1)
      que.push_back(query(a, b, (int)(upd).size(), (int)(que).size()));
    else
      upd.push_back(make_pair(a, b)), V.push_back(b);
  }
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  for (int i = (1); i < (n + 1); i++)
    data[i] = lower_bound(V.begin(), V.end(), data[i]) - V.begin() + 1;
  for (int i = (0); i < ((int)(upd).size()); i++)
    upd[i].second =
        lower_bound(V.begin(), V.end(), upd[i].second) - V.begin() + 1;
  sort(que.begin(), que.end(), cmp);
  for (int i = (0); i < ((int)(que).size()); i++) {
    while (l > que[i].l) {
      l--;
      add(data[l]);
    }
    while (r < que[i].r) {
      r++;
      add(data[r]);
    }
    while (r > que[i].r) {
      del(data[r]);
      r--;
    }
    while (l < que[i].l) {
      del(data[l]);
      l++;
    }
    while (t < que[i].t) {
      int pos = upd[t].first;
      S.push(make_pair(pos, data[pos]));
      if (l <= pos && pos <= r) del(data[pos]);
      data[pos] = upd[t].second;
      if (l <= pos && pos <= r) add(data[pos]);
      t++;
    }
    while (t > que[i].t) {
      t--;
      int pos = S.top().first;
      if (l <= pos && pos <= r) del(data[pos]);
      data[pos] = S.top().second;
      if (l <= pos && pos <= r) add(data[pos]);
      S.pop();
    }
    que[i].ans = Ans;
  }
  sort(que.begin(), que.end(), cmpid);
  for (int i = (0); i < ((int)(que).size()); i++) printf("%d\n", que[i].ans);
  return 0;
}