#include <bits/stdc++.h>
using namespace std;

const int MOD = 998244353, maxn = 1e6, inf = 1e9 + 7;
vector<int> g[maxn];
mt19937 rnd(55);

int tme[maxn], a[maxn];
int n, q;

struct Node {
    int pos1, c1, pos2, c2;
    Node (int pos = inf, int c = -1) {
        pos1 = pos;
        c1 = c;
        pos2 = inf;
        c2 = -1;
    }
    Node operator + (const Node & other) const {
        Node res;
        if (pos1 <= other.pos1) {
            res.pos1 = pos1;
            res.c1 = c1;
        } else {
            res.pos1 = other.pos1;
            res.c1 = other.c1;
        }
        if (pos1 < res.pos2 && c1 != res.c1) {
            res.pos2 = pos1;
            res.c2 = c1;
        }
        if (other.pos1 < res.pos2 && other.c1 != res.c1) {
            res.pos2 = other.pos1;
            res.c2 = other.c1;
        }
        if (pos2 < res.pos2 && c2 != res.c1) {
            res.pos2 = pos2;
            res.c2 = c2;
        }
        if (other.pos2 < res.pos2 && other.c2 != res.c1) {
            res.pos2 = other.pos2;
            res.c2 = other.c2;
        }
        return res;
    }
};

Node t[maxn * 4];


void build(int v, int l, int r) {
    if (l + 1 == r) {
        t[v] = Node(l, a[l]);
        return;
    }
    int mid = (l + r) / 2;
    build(v * 2, l, mid);
    build(v * 2 + 1, mid, r);
    t[v] = t[v * 2] + t[v * 2 + 1];
}

void update(int v, int l, int r, int pos) {
    if (pos < l || pos >= r) return;
    if (l + 1 == r) {
        t[v] = Node(inf, a[pos]);
        return;
    }
    int mid = (l + r) / 2;
    update(v * 2, l, mid, pos);
    update(v * 2 + 1, mid, r, pos);
    t[v] = t[v * 2] + t[v * 2 + 1];
}

void rebuild() {
    build(1, 0, n);
    int lastcol = -1;
    for (int i = 0; i < n; i++) {
        Node res = t[1];
        //cout << res.pos1 << ' ' << res.c1 << " " << res.pos2 << " " << res.c2 << " " << endl;
        if (res.c1 != lastcol || res.c2 == lastcol || res.pos2 == inf) {
            //cout << res.pos1 << "\n";
            tme[res.pos1] = i + 1;
            lastcol = res.c1;
            update(1, 0, n, res.pos1);
        } else {
            tme[res.pos2] = i + 1;
            //cout << res.pos2 << "\n";
            lastcol = res.c2;
            update(1, 0, n, res.pos2);
        }
    }
    //cout << "DEBUG\n";
}

void solve() {
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    rebuild();
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x; x--;
            swap(a[x], a[x + 1]);
            rebuild();
        } else {
            int x;
            cin >> x; x--;
            cout << tme[x] << "\n";
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tests = 1;
    while (tests--) {
        solve();
    }
}
