#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // если я не наберу 100 за тур = лошара
    int n, q;
    cin >> n >> q;
    vector <int> a(n);
    bool group1 = (n <= 500 && q <= 500),
        group7 = true;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] < 1 || a[i] > 2)
            group7 = false;
    }
    auto get_order = [&]() {
        vector <int> ans(n);
        vector <bool> got(n, false);
        int last = -1;
        for (int c = 0; c < n; ++c) {
            bool nn = false;
            for (int i = 0; i < n; ++i) {
                if (got[i])
                    continue;
                if (last != -1 && a[last] == a[i])
                    continue;
                ans[i] = c;
                last = i;
                got[i] = nn = true;
                break;
            }
            if (!nn) {
                for (int i = 0; i < n; ++i) {
                    if (!got[i]) {
                        ans[i] = c;
                        ++c;
                    }
                }
                break;
            }
        }
        return ans;
    };
    if (group1) {
        while (q--) {
            int type, c;
            cin >> type >> c;
            --c;
            if (type == 1) {
                swap(a[c], a[c + 1]);
            } else {
                cout << get_order()[c] + 1 << "\n";
            }
        }
        return 0;
    }
    return 0;
}
