#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()

vector<int> sol(vector<int>a ) {
    int n = sz(a);
    vector<int> used(n),ans(n);
    int lst = -1;
    for (int j = 0; j < n; j++) {
        bool f = false;
        for (int i = 0; i < n; i++) {
            if (a[i]!=lst&&!used[i]) {
                lst=a[i];
                ans[i] = j+1;
                used[i]=1;
                f=1;
                break;
            }
        }
        if (!f) {
            for (int i = 0; i< n;i++) {
                if (!used[i]) {
                    ans[i] = j + 1;
                    used[i]=1;break;
                }
            }
        }
    }
    return ans;
}

vector<int> kek(vector<int> a){
    vector<int>ans(sz(a));
    for (int j = 0; j < sz(a);j ++) ans[a[j] - 1] = j;
    return ans;
}

void solve() {
    int n,q ; cin >>n >> q;
    vector<int> a(n);
    for(auto&u:a) cin >> u;
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int x; cin >>x ;
            x--;
            auto was = sol(a);
            swap(a[x], a[x + 1]);
            auto cur = sol(a);
            cur=kek(cur);
            int cnt = 0;
            int mx=0;
            vector<int> g1(n), g2(n);
            for(int j= 0; j<sz(cur); j++) {
                mx=max(mx, cur[j]);
               g1[j] = (mx==j);
            }
            // cout << '\n';
            for (int j = 0; j < n; j++) cnt += (cur[j] != was[j]);
            was=kek(was);
            mx = 0;
            for(int j= 0; j<sz(cur); j++) {
                mx=max(mx, was[j]);
                g2[j] = (mx==j);
            }
            int cntt=0;
            for (int j=0;j<n;j++) cntt += (g1[j]!=g2[j]);
            // for(auto u : g1) cout << u << ' ';
            // cout << endl;
            // for(auto u : g2) cout << u << ' ';
            // cout << endl;
            assert(cntt <= 3);
            // cout << '\n';
            // assert(cnt <= 4);
        } else {
            int y; cin >> y;
            y--;
            cout << sol(a)[y] << '\n';
        }
        // for (auto &u : sol(a)) cout << u << ' ';
        // cout<< endl;
    }
}

signed main() {
    int t = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> t;
    #else 
        cin.tie(0)->sync_with_stdio(false);
    #endif 

    while (t--) solve();

    return 0;
}