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;
const int SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int B = 3000;
struct Query {
  int l, r, t, idx, bl, br;
  Query(int l, int r, int t, int idx)
      : l(l), r(r), t(t), idx(idx), bl(l / B), br(r / B) {}
  bool operator<(const Query &q) const {
    return tuple<int, int, int>(bl, br, t) <
           tuple<int, int, int>(q.bl, q.br, q.t);
  }
};
const int MAX = 100005;
int cnt[MAX], v[MAX], ocur[2 * MAX];
vector<pair<int, int> > updateForward, updateBackward;
void add(int pos) {
  int x = v[pos];
  cnt[ocur[x]]--;
  cnt[++ocur[x]]++;
}
void remove(int pos) {
  int x = v[pos];
  cnt[ocur[x]]--;
  cnt[--ocur[x]]++;
}
void applyUpdate(pair<int, int> upd, int l, int r) {
  auto [pos, val] = upd;
  if (l <= pos && pos <= r) remove(pos);
  v[pos] = val;
  if (l <= pos && pos <= r) add(pos);
}
int getAns() {
  int res = 0;
  while (cnt[res]) res++;
  return res;
}
vector<int> MO(vector<Query> queries) {
  cnt[0] = 0x3f3f3f3f;
  int l = 0, r = -1, t = 0;
  vector<int> ans(queries.size());
  sort(queries.begin(), queries.end());
  for (auto q : queries) {
    while (t < q.t) applyUpdate(updateForward[t++], l, r);
    while (q.t < t) applyUpdate(updateBackward[--t], l, r);
    while (q.l < l) add(--l);
    while (r < q.r) add(++r);
    while (l < q.l) remove(l++);
    while (q.r < r) remove(r--);
    ans[q.idx] = getAns();
  }
  return ans;
}
void create_queries(vector<pair<int, int> > updates) {
  int n = updates.size();
  for (int i = 0; i < n; i++) {
    auto [pos, val] = updates[i];
    updateForward.emplace_back(pos, val);
    updateBackward.emplace_back(pos, v[pos]);
    v[pos] = val;
  }
  for (int i = n - 1; i >= 0; i--) {
    auto [pos, val] = updateBackward[i];
    v[pos] = val;
  }
}
map<int, int> mp;
int compress(int x) {
  if (!mp.count(x)) mp[x] = mp.size();
  return mp[x];
}
void test_case() {
  int n, q, type, l, r, x;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v[i] = compress(x);
  }
  vector<pair<int, int> > updates;
  vector<Query> queries;
  for (int i = 0; i < q; i++) {
    cin >> type >> l >> r;
    if (type == 1)
      queries.emplace_back(l - 1, r - 1, updates.size(), queries.size());
    if (type == 2) updates.emplace_back(l - 1, compress(r));
  }
  create_queries(updates);
  vector<int> res = MO(queries);
  for (auto x : res) cout << x << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    test_case();
  }
  return 0;
}