#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>

#define ll long long
#define ld long double
#define ull unsigned long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using namespace std;

const int MAX = 2e9;
const int MIN = -2e9;
const int mod = 998244353;

int add(int a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0) {
        a += mod;
    }
    return a;
}

int mul(int a, int b) {
    return (ll) a * b % mod;
}

int binpow(int a, ll k) {
    int res = 1;
    while (k) {
        if (k % 2) {
            res = mul(res, a);
        }
        a = mul(a, a);
        k /= 2;
    }
    return res;
}

struct node {
    int mn, ind;
};

node merge(node a, node b) {
    if (a.mn < b.mn) {
        return a;
    }
    return b;
}

struct segtree {
    const node ZERO = {MAX, 0};
    vector<node> t;
    int size;


    void init(int n) {
        size = 1;
        while (size < n) {
            size *= 2;
        }
        t.assign(size * 2 - 1, ZERO);
    }

    void build(int v, vector<int> &a, int tl, int tr) {
        if (tr - tl == 1) {
            if (tl < a.size()) {
                t[v] = {a[tl], tl};
            }
            return;
        }
        int mid = (tl + tr) / 2;
        build(v * 2 + 1, a, tl, mid);
        build(v * 2 + 2, a, mid, tr);
        t[v] = merge(t[v * 2 + 1], t[v * 2 + 2]);
    }

    void build(vector<int> &a) {
        init(a.size());
        build(0, a, 0, size);
    }

    node get(int v, int l, int r, int tl, int tr) {
        if (tr <= l or tl >= r) {
            return ZERO;
        }
        if (tl >= l and tr <= r) {
            return t[v];
        }
        int mid = (tl + tr) / 2;
        return merge(get(v * 2 + 1, l, r, tl, mid), get(v * 2 + 2, l, r, mid, tr));
    }

    node get(int l, int r) {
        return get(0, l, r, 0, size);
    }

    void update(int v, int ind, int x, int tl, int tr) {
        if (tr - tl == 1) {
            t[v] = {x, tl};
            return;
        }
        int mid = (tl + tr) / 2;
        if (ind < mid) {
            update(v * 2 + 1, ind, x, tl, mid);
        } else {
            update(v * 2 + 2, ind, x, mid, tr);
        }
        t[v] = merge(t[v * 2 + 1], t[v * 2 + 2]);
    }

    void update(int ind, int x) {
        update(0, ind, x, 0, size);
    }
};

void dany() {
    int n,q;
    cin >> n>>q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    while (q--) {
        int type,x;
        cin>>type>>x;
        x--;
        if (type==1) {
            swap(a[x],a[x+1]);
        }
        else {
            vector<int> c(n, MAX);
            vector<vector<int> > col(n);
            for (int i = 0; i < n; i++) {
                if (col[a[i]].empty()) {
                    c[a[i]] = i;
                }
                col[a[i]].push_back(i);
            }
            for (int i=0;i<n;i++) {
                reverse(all(col[i]));
            }
            segtree t;
            t.build(c);
            int pos = -1;
            vector<int> p,id(n);
            for (int i = 0; i < n; i++) {
                node ans= merge(t.get(0, pos), t.get(pos + 1, n));
                int ind = ans.ind;
                if (ans.mn==MAX) {
                    ind=pos;
                }
                id[col[ind].back()]=p.size();
                p.push_back(col[ind].back());
                col[ind].pop_back();
                int x=MAX;
                if (col[ind].size()) {
                    x=col[ind].back();
                }
                t.update(ind,x);
                pos=ind;
            }
            cout<<p[x]+1<<'\n';
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    dany();
    return 0;
}
