#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include "testlib.h"
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;


int main(int argc, char* argv[]) {
	registerGen(argc, argv, 1);

	int n = opt<int>("n");
	int mina = opt<int>("mina");
	int maxa = opt<int>("maxa");
	int q = opt<int>("q");
	double padd = (has_opt("padd") ? opt<double>("padd") : 0.5);
	
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = rnd.next(mina, maxa);
	}
	if (has_opt("sorted") && opt<bool>("sorted")) {
		sort(a.rbegin(), a.rend());
	}

	cout << n << "\n";
	vector<int> nons;
	vector<int> pos(n, -1);
	for (int i = 0; i < n; i++) {
		cout << a[i] << " \n"[i == n - 1];
		if (a[i] > 0) {
			pos[i] = (int) nons.size();
			nons.push_back(i);
		}
	}

	cout << q << '\n';
	for (int i = 0; i < q; i++) {
		int p = (rnd.next() < padd ? 1 : 2);
		if (nons.empty()) {
			p = 1;
		}
		int v;
		if (p == 1) {
			v = rnd.next(0, n - 1);
			if (a[v] == 0) {
				pos[v] = (int) nons.size();
				nons.push_back(v);
			}
			a[v] += 1;
	        } else {
	        	v = nons[rnd.next(0, (int) nons.size() - 1)];
	        	a[v] -= 1;
	        	if (a[v] == 0) {
	        		int at = pos[v];
	        		nons[at] = nons.back();
	        		pos[nons[at]] = at;
	        		nons.pop_back();
	        		pos[v] = -1;
	        	}
	        }
	        cout << p << " " << v << '\n';
	}

	return 0;
}