#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, k;
ll a[2000005];
deque <ll> p[305];
struct ANS {
    struct node {
        ll a,b,c;
    };
    vector<node>dat;
    vector<node>::iterator add( ll op, ll x, ll y = 0 ) {
        dat.push_back({op,x,y});
        return dat.end()-1;
    }
    void print() {
        printf("%ld\n",dat.size());
        for ( auto x : dat ) {
            if ( x.a == 1 ) printf("1 %lld\n",x.b);
            else printf("2 %lld %lld\n",x.b,x.c);
        }
        dat.clear();
    }
} ans;
ll work( ll x ) {
    ll flag = 3, r = 0;
    for ( ll i = 1 ; i < n; ++i ) {
        if ( p[i].back() == a[x] ) {
            flag = 1;
            r = i;
            break;
        } else if ( p[i].front() == a[x] ) {
            flag = 2;
            r = i;
            break;
        } else if ( p[i].size() < 2 ) {
            flag = 0;
            r = i;
            break;
        }
    }
    if ( flag == 0 ) {
        p[r].push_back(a[x]);
        ans.add(1,r);
    } else if ( flag == 1 ) {
        p[r].pop_back();
        ans.add(1,r);
    } else if ( flag == 2 ) {
        p[r].pop_front();
        ans.add(1,n);
        ans.add(2,r,n);
    } else if ( flag == 3 ) {
        auto tmp = ans.add(1,0);
        for ( ll j = x+1; j <= m; ++j ) {
            ll tmp1 = [j]() {
                for ( ll i = 1 ; i < n ; ++i ) {
                    if ( p[i].empty() ) continue;
                    if ( p[i].front() == a[j] ) return i;
                    if ( p[i].back() == a[j] ) return i;
                }
                return 0ll;
            }();
            if ( p[tmp1].front() == a[j] ) {
                if ( p[tmp1].size() == 2 ) {
                    tmp->b = tmp1;
                    ans.add(1,n);
                    ans.add(2,tmp1,n);
                    return j + 1;
                } else {
                    tmp->b = n;
                    ans.add(1,tmp1);
                    p[tmp1].pop_back();
                    p[tmp1].swap(p[n]);
                }
            }
            if ( p[tmp1].back() == a[j] ) {
                ans.add(1,tmp1);
                p[tmp1].pop_back();
            }
        }
        return (m+1);
    }
    return x+1;
}
// 没时间了，悲...