#pragma GCC optimize("O3, unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define int long long

const int mod =998244353;

int n;
vector<int> a;

const int N = 1e5;
vector<bitset<N>> all;

vector<int> ans() {
    int n = (int) a.size();
    vector<int> res;
    vector<int> ids(n);
    bitset<N> b;
    for (int i = 0; i < n; i++) {
        b[i] = 1;
    }
    res.push_back(a[0]);
    all[a[0]][0] = 0;
    b[0] = 0;
    ids[0] = 1;
    while ((int) res.size() < n) {
        int x = res.back();
        b ^= all[x];
        if (b.count() == 0) {
            b |= all[x];
            break;
        }
        int i = b._Find_first();
        ids[i] = (int) res.size() + 1;
        res.push_back(a[i]);
        all[a[i]][i] = 0;
        b[i] = 0;
        b |= all[x];
    }
    for (int i = 0; i < n; i++) {
        all[a[i]][i] = 1;
        if (b[i]) {
            ids[i] = (int) res.size() + 1;
            res.push_back(a[i]);
        }
    }
    return ids;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int q;
    cin >> n >> q;
    a.assign(n, 0);
    all.assign(n, {});
    for (int i = 0; i < n; i++) {
        cin >> a[i]; a[i]--;
        all[a[i]][i] = 1;
    }
    vector<int> res = ans();
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >> x; x--;
            all[a[x]][x] = 0;
            all[a[x + 1]][x + 1] = 0;
            swap(a[x], a[x + 1]);
            all[a[x]][x] = 1;
            all[a[x + 1]][x + 1] = 1;
            res = ans();
        } else {
            int idx; cin >> idx; idx--;
            cout << res[idx] << "\n";
        }
    }

}