#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <deque>
using namespace std;
using ll = long long;
constexpr int MAXN = 500;
bool used[MAXN];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (auto &v : a)
		cin >> v;
	while (q--) {
		int type;
		cin >> type;
		if (type == 1) {
			int x;
			cin >> x;
			x--;
			swap(a[x], a[x + 1]);
		} else {
			fill(used, used + MAXN, false);
			int y;
			cin >> y;
			y--;
			int prev = -1;
			vector<int> hh;
			for (int i = 0; i < n; i++) {
				bool ok = false;
				for (int j = 0; j < n; j++) {
					if (!used[j] && a[j] != prev) {
						ok = true;
						used[j] = true;
						hh.push_back(j);
						prev = a[j];
						break;
					}
				}
				if (!ok) {
					for (int j = 0; j < n; j++) {
						if (!used[j]) {
							used[j] = true;
							hh.push_back(j);
						}
					}
				}
			}
			cout << hh[y] + 1 << "\n";
		}
	}
	return 0;
}
