#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vll = vector<ll>;

vector<ll> get(vector<ll> &a) {
    ll n = a.size();
    vector<ll> res(n), used(n);
    ll last = -1;
    ll ptr = 0;

    while (ptr < n) {
        bool flag = false;
        for (ll i = 0; i < n; i++) {
            if (!used[i] && a[i] != last) {
                last = a[i];
                res[i] = ptr + 1;
                used[i] = true;
                ptr++;
                flag = true;
                break;
            }
        }

        if (flag) continue;
        for (ll i = 0; i < n; i++) {
            if (!used[i]) {
                last = a[i];
                res[i] = ptr + 1;
                used[i] = true;
                ptr++;
                break;
            }
        }
    }

    return res;
}

vector<ll> get2(vector<ll> &a) {
    ll n = a.size();
    vector<ll> res(n), used(n);
    ll last = -1;
    ll ptr = 0;

    while (ptr < n) {
        bool flag = false;
        for (ll i = 0; i < n; i++) {
            if (!used[i] && a[i] != last) {
                last = a[i];
                res[i] = last;
                used[i] = true;
                ptr++;
                flag = true;
                break;
            }
        }

        if (flag) continue;
        for (ll i = 0; i < n; i++) {
            if (!used[i]) {
                last = a[i];
                res[i] = last;
                used[i] = true;
                ptr++;
                break;
            }
        }
    }

    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, q;
    cin >> n >> q;

    vector<ll> a(n);
    for (ll &i: a)
        cin >> i;

    vector<ll> t = get(a);
    vector<ll> from = get(a);

    while (q--) {
        ll i, j;
        cin >> i >> j;
        j--;

        if (i == 1) {
            if (a[j] == a[j + 1])
                continue;

            swap(a[j], a[j + 1]);
            t = get(a);
            continue;
        }

        t = get(a);
        cout << t[j] << '\n';
    }
}
