#include <bits/stdc++.h>
//#include <bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;
using pic = pair<ll, char>;
using ull = unsigned long long;
//using oset = tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd('S' + 'E' + 'E' + 'D');
ll l_r(const ll &lb_, const ll &rb_) {return (lb_ + rnd() % (rb_ - lb_ + 1)); }
template<class T> ll szl(const T &v1) { return (ll)v1.size(); }
template<class T> bool mmin(T &v1, const T &v2) { return (v1 > v2 ? v1 = v2, 1 : 0); }
template<class T> bool mmax(T &v1, const T &v2) { return (v1 < v2 ? v1 = v2, 1 : 0); }
#ifndef MiracleFFT
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx,avx2,bmi,bmi2,lzcnt,popcnt")
#endif
const ll INF = 2e9 + 10;
const ll LNF = 2e18 + 10;
const ll MAXN = 2e5 + 10;
const ll MAXX = 1e9 + 10;
const ll MAXC = 1e18 + 10;
const ll ALPH = 26;
const ll BL_SZ = 400;
const ll MAX_LOG = 20;
const ll CNT_OP = 10;
const ll MOD = 1e9 + 7;
const ll P = 179;
const ll M = 1e9 + 787;
const ld UNO = ld(1.0);
const ld PI = atan2(0, -1);
const ld BURN = ld(0.99999);


void solve() {
    ll n, q;
    cin >> n >> q;

    vector<ll> a(n);
    for (auto &el : a) {
        cin >> el;
        --el;
    }


    ll pcol = -1;
    vector<ll> us(n);

    vector<ll> o(n);
    vector<ll> id(n);
    auto paint = [&](ll i) {
        ll to = -1;
        ll pcol = -1;
        if (i) pcol = a[o[i - 1]];
        for (ll j = 0; j < n; j++) {
            if (us[j] || a[j] == pcol) {
                continue;
            }
            to = j;
            break;
        }
        if (to == -1) {
            for (ll j = 0; j < n; j++) {
                if (us[j]) {
                    continue;
                }
                to = j;
                break;
            }
        }
        o[i] = to;
        id[to] = i;
        us[to] = 1;
    };
    auto clr = [&](ll i) {
        us[o[i]] = 0;
        o[i] = -1;
    };
    for (ll i = 0; i < n; i++) {
        paint(i);
    }

    while (q--) {
        ll tt;
        cin >> tt;
        if (tt == 1) {
            ll s;
            cin >> s;
            --s;
            if (a[s] == a[s + 1]) {
                continue;
            }
            swap(a[s], a[s + 1]);
            ll st = min(id[s], id[s + 1]);
            for (ll j = st; j < min(n, st + CNT_OP); j++) {
                clr(j);
            }
            for (ll i = st; i < min(n, st + CNT_OP); i++) {
                paint(i);
            }
        } else {
            ll i;
            cin >> i;
            --i;
            cout << id[i] + 1 << '\n';
        }
    }
}


int main() {
    bool IS_MULTITEST = 0; 
    #ifdef MiracleFFT
        IS_MULTITEST = 1;
        freopen("ain.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(9) << fixed;
    ll t = 1;
    if (IS_MULTITEST) {
        cin >> t;
    }
    while (t--) {
        solve();
    }
    #ifdef MiracleFFT
        cout << setprecision(2) << fixed;
        cout << "Time: " << ((ld)clock() / CLOCKS_PER_SEC) << " Sec" << endl;
    #endif
}
