// template.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #define int long long

using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 998244353;

int modpow(int a, int b)
{
    if (b == 0)
        return 1;
    if (b & 1)
        return 1ll * a * modpow(a, b - 1) % MOD;
    return modpow(1ll * a * a % MOD, b >> 1);
}

vector <int> calc(const vector <int>& a)
{
    int n = a.size();
    vector <int> b;
    int pr = -1;
    deque<int> raw;
    for (size_t i = 0; i < n; i++)
    {
        if (a[i] != pr)
        {
            b.push_back(i);
            if (!raw.empty())
            {
                b.push_back(raw.front());
                raw.pop_front();
            }
            else
            {
                pr = a[i];
            }
        }
        else
        {
            raw.push_back(i);
        }
    }
    for (auto& i : raw)
    {
        b.push_back(i);
    }
    return b;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector <int> a(n);
    for (auto& i : a)
    {
        cin >> i;
    }
    a.resize(max(a.size(), (size_t)10));
    unordered_map<int, unordered_map<int, int>> um;
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int x;
            cin >> x;
            x--;
            swap(a[x], a[x + 1]);
        }
        else
        {
            int y;
            cin >> y;
            y--;
            // cout << calc(a, y) + 1 << '\n';
            int hsh = a[0] + a[1] * 7 + a[2] * 49 + a[4] * 2481 + a[5] * 4824713 + a[6] * 43444444 + a[7] * 4820 + a[8] * 484221;
            auto it = um.find(hsh);
            if (it == um.end())
            {
                auto t = calc(a);
                unordered_map<int, int>um2;
                for (size_t i = 0; i < n; i++)
                {
                    um2[t[i]] = i;
                }
                cout << um2[y] + 1 << '\n';
                um[hsh] = um2;
            }
            else
            {
                cout << it->second[y] + 1 << '\n';
            }
        }
    }
    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
