#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

void fast_in_out() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(18) << fixed;
#ifdef LOCAL
    freopen("input.txt", "r",stdin);
    freopen("output.txt", "w",stdout);
#endif
}

typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define all(x) (x).begin(), (x).end()
#define int long long
using ll = long long;
const int N = 5e5;
int n, q, c[N];
pair<int, int> a[N];
int pos[N];

void solve() {
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        --y;
        if (x == 1) {
            swap(c[y], c[y + 1]);
        } else {
            vector<int> used(n);
            int pos1 = 0, pos2 = 0;
            for (int i = 0; i < n; ++i) {
                a[i].first = 0;
                int ps = i == 0 ? -1 : a[i - 1].first;
                while (true) {
                    if (pos1 < n && used[pos1]) {
                        ++pos1;
                        continue;
                    }
                    if (pos2 < n && used[pos2]) {
                        ++pos2;
                        continue;
                    }
                    if (pos1 > pos2) {
                        swap(pos1, pos2);
                    }
                    if (pos1 < n && pos2 < n && c[pos1] == c[pos2]) {
                        ++pos2;
                        continue;
                    }
                    break;
                }
                if (pos1 < n && c[pos1] != ps) {
                    a[i] = {c[pos1], pos1};
                    pos[pos1] = i;
                    used[pos1] = 1;
                    ++pos1;
                    continue;
                }
                if (pos2 < n && c[pos2] != ps) {
                    a[i] = {c[pos2], pos2};
                    pos[pos2] = i;
                    used[pos2] = 1;
                    ++pos2;
                    continue;
                }
                a[i] = {c[pos1], pos1};
                pos[pos1] = i;
                used[pos1] = 1;
                ++pos1;
            }
            cout << pos[y] + 1 << '\n';
        }
    }
}

signed main() {
    fast_in_out();
    int qwe = 1;
    // cin >> qwe;
    while (qwe--) {
        solve();
    }
}
