#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

// #define int long long

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define rep(i,j,k) for (int (i) = (j); (i) < (k); ++i)
#define rrep(i,j,k) for (int (i) = (j); (i) >= (k); --i)
#define re return
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

using ordered_set = tree<int, less<>, null_type, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_multiset = tree<int, less_equal<>, null_type, rb_tree_tag, tree_order_statistics_node_update>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using si = set<int>;
using msi = multiset<int>;

void amin(int& a, int b) {
    a = min(a, b);
}

void amax(int& a, int b) {
    a = max(a, b);
}

void solve();

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
}

/* ------------------------------------- ACTUAL CODE STARTS HERE ------------------------------------- */

int bin_pow(int a, int b, int mod) {
    if (b == 0) re 1;
    if (b % 2 == 0) {
        int x = bin_pow(a, b / 2, mod);
        re (x * x) % mod;
    }
    re (a * bin_pow(a, b - 1, mod)) % mod;
}

const int MOD = 998244353, MAXN = 505, INF = 2e18;

vi order(vi& a) {
    deque<tuple<int, int, int>> blocks;
    rep(i, 0, a.size()) {
        if (blocks.empty() || get<1>(blocks.back()) != a[i]) {
            blocks.pb({i, a[i], 1});
        } else {
            auto& [x, y, z] = blocks.back();
            z++;
        }
    }
    vi ord;
    int last = -1;
    int cntt = 0;
    while (blocks.size() > 1) {
        int chet = 0;
        while (chet < blocks.size() && get<1>(blocks[chet]) == last) {
            chet++;
        }
        if (chet == blocks.size()) break;
        auto& [pos1, val1, cnt1] = blocks[chet];
        last = val1;
        ord.pb(pos1 + 1);
        pos1++;
        cnt1--;
        int szz = min(100, (int)blocks.size());
        vector<tuple<int, int, int>> vecc;
        rep(i, 0, szz) {
            if (get<2>(blocks[i]) != 0) {
                vecc.pb(blocks[i]);
            }
        }
        while (szz--) {
            blocks.pop_front();
        }
        reverse(all(vecc));
        for (auto pp : vecc) {
            blocks.push_front(pp);
        }
    }
    while (!blocks.empty()) {
        auto& [x, y, z] = blocks[0];
        ord.pb(x + 1);
        x++;
        z--;
        while (!blocks.empty() && get<2>(blocks[0]) == 0) {
            blocks.pop_front();
        }
    }
    vi halva(a.size() + 1, 0);
    rep(i, 0, ord.size()) {
        halva[ord[i]] = i + 1;
    }
    re halva;
}

void solve() {
    int n, q; cin >> n >> q;
    vi a(n); for (int& x : a) cin >> x;
    vi ord = order(a);
    while (q--) {
        int type; cin >> type;
        if (type == 1) {
            int pos; cin >> pos; pos--;
            swap(a[pos], a[pos + 1]);
            ord = order(a);
        } else {
            int pos; cin >> pos;
            cout << ord[pos] << "\n";
        }
    }
}