#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
const ll MAXN = 1e5 + 6;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
mt19937 rnd(2);
ll ans[MAXN];

int main() {
    ll n, q, a, b;
    cin >> n >> q;
    vector<ll> arr;
    for (int i = 0; i < n; i++) {
        cin >> a;
        arr.push_back(a);
    }
    vector<ll> index(n, 0);
    vector<ll> un_index(n, 0);
    deque<pair<ll, ll> > st;
    ll color = -1;
    ll p = 0;
    for (int i = 0; i < n; i++) {
        if (color == arr[i]) {
            st.push_back({arr[i], i});
        } else {
            index[p] = i;
            un_index[i] = p;
            color = arr[i];
            p++;
            if (st.size() > 0) {
                index[p] = st.front().second;
                un_index[st.front().second] = p;
                color = st.front().first;
                st.pop_front();
                p++;
            }
        }
    }
    for (int j = 0; j < st.size(); j++) {
        index[p] = st[j].second;
        un_index[st[j].second] = p;
        p++;
    }
    for (int tr = 0; tr < q; tr++) {
        cin >> a >> b;
        b--;
        if (a == 1) {
            ll x = un_index[b];
            ll y = un_index[b + 1];
            swap(arr[b], arr[b + 1]);
            if ((arr[b] == arr[b + 1]) || (arr[b] != 1 && arr[b + 1] != 1)) {
                continue;
            }
            if (arr[b+1] == 1) {
                if (un_index[b] > un_index[b+1]) {
                    swap(un_index[b], un_index[b + 1]);
                    swap(index[x], index[y]);
                }
            }
            else {
                if (un_index[b] > 0 && arr[index[un_index[b] -1]] == 1) {
                    swap(un_index[b], un_index[b + 1]);
                    swap(index[x], index[y]);
                }
            }
        } else {
            cout << un_index[b] + 1 << "\n";
        }
    }
}
