#include<bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < q; i++) {
        int t, x;
        cin >> t >> x;
        x--;
        if (t == 1) {
            swap(a[x], a[x + 1]);
        }
        else {
            vector<int> order;
            vector<int> b = a;
            order.push_back(0);
            b[0] = -1;
            for (int i = 0; i < n - 1; i++) {
                int j;
                for (j = 0; j < n; j++) {
                    if (b[j] != -1 && b[j] != a[order.back()]){
                        break;
                    }
                }
                if (j != n) {

                    order.push_back(j);
                    b[j] = -1;
                }
                else {
                    for (j = 0; j < n; j++) {
                        if (b[j] != -1) break;
                    }
                    order.push_back(j);
                    b[j] = -1;
                }
            }
            // for (int i: order) cout << i << ' ';
            // cout << endl;
            for (int i = 0; i < n; i++) {
                if (order[i] == x) cout << i + 1 << ' ';
            }
        }
    }
    return 0;        
}