import java.io.*;
import java.util.*;

public class TestsGen implements Runnable {
	public static void main(String[] args) {
		new TestsGen().run();
	}

	public int done = 0;
	ArrayList<String> data = new ArrayList<String>();

	final int MAXN = 1000;
	final int MAXGAP = (int) 1e4;
	final int INF = (int) 1e9;

	public void print() throws IOException {
		done++;
		System.err.println(done);
		PrintWriter out;
		if (done < 10)
			out = new PrintWriter("0" + String.valueOf(done));
		else
			out = new PrintWriter(String.valueOf(done));

		for (int i = 0; i < data.size(); i++)
			out.println(data.get(i));
		out.println();
		out.close();
	}

	public void genRand(int n, int minTrees, int maxTrees, int code)
			throws IOException {
		data.clear();
		int[] ans = new int[n + 2];
		Arrays.fill(ans, INF);
		ArrayList<ArrayList<Integer>> cur = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < n; i++) {
			int k = nextInt(minTrees, maxTrees);
			cur.add(new ArrayList<Integer>());
			cur.get(i).add(k);
			for (int j = 0; j < k - 1; j++) {
				int val = nextInt(2, MAXGAP);
				if (i == 0 || val > ans[i - 1]) {
					ans[i] = Math.min(ans[i], val);
				}
				cur.get(i).add(val);
			}
		}
		if (code == 0) {
			int val = nextInt(1, n - 1);
			int k = nextInt(minTrees, maxTrees);
			ArrayList<Integer> bad = new ArrayList<Integer>();
			bad.add(k);
			for (int i = 0; i < k; i++) {
				bad.add(nextInt(1, ans[val - 1] - 1));
			}
			n++;
			for (int i = 0; i < val; i++) {
				String toAdd = "";
				int kk = cur.get(i).get(0);
				for (int j = 0; j < kk; j++) {
					if (j != 0)
						toAdd += " ";
					toAdd += cur.get(i).get(j);
				}
				data.add(toAdd);
			}

			{
				String toAdd = "";
				int kk = bad.get(0);
				for (int j = 0; j < kk; j++) {
					if (j != 0)
						toAdd += " ";
					toAdd += bad.get(j);
				}
				data.add(toAdd);
			}
			for (int i = val; i < n - 1; i++) {
				String toAdd = "";
				int kk = cur.get(i).get(0);
				for (int j = 0; j < kk; j++) {
					if (j != 0)
						toAdd += " ";
					toAdd += cur.get(i).get(j);
				}
				data.add(toAdd);
			}

		} else if (code == 1) {
			if (ans[n - 1] == INF) {
				int pos = n - 2;
				for (; pos >= 0 && ans[pos] == INF; pos--)
					;
				int val = ans[pos];
				for (; pos < n; pos++) {
					int curK = cur.get(pos).get(0);
					int rPos = nextInt(1, curK - 1);
					val = nextInt(val, MAXGAP);
					cur.get(pos).set(rPos, val);
				}

			}
		}
		if (code == -1 || code == 1) {
			for (int i = 0; i < n; i++) {
				String toAdd = "";
				int kk = cur.get(i).get(0);
				for (int j = 0; j < kk; j++) {
					if (j != 0)
						toAdd += " ";
					toAdd += cur.get(i).get(j);
				}
				data.add(toAdd);
			}
		}

		data.add(0, n + "");
		print();
	}

	public int nextInt(int low, int high) {
		int base = high - low + 1;
		int val = rnd.nextInt();
		val %= base;
		while (val < 0)
			val += base;
		val += low;
		return val;
	}

	public void genSingleSeq(int n, int code) throws IOException {
		data.clear();
		data.add("" + n);
		int val = 2;
		for (int i = 0; i < n; i++) {
			if (code == 0 && rnd.nextBoolean()) {
				val = nextInt(1, Math.max(1, val - 1));
			}
			val = nextInt(val, MAXGAP);
			data.add(2 + " " + val);
		}
		print();
	}

	Random rnd;

	public void run() {
		try {
			rnd = new Random(346);

			for (int i = 0; i < 5; i++) {
				genRand(2, 2, 10, -1);
			}
			for (int i = 0; i < 5; i++) {
				genRand(2, 20, MAXN, -1);
			}

			int prev = 50;
			for (int i = 0; i < 5; i++) {
				genRand(prev, 2, MAXN, -1);
				prev = nextInt(Math.min(prev + 100, MAXN), MAXN);
			}

			genSingleSeq(100, 0);
			genSingleSeq(100, 1);
			genSingleSeq(1000 - 1, 0);
			genSingleSeq(1000, 1);

			genRand(100, 2, MAXN, 0);
			genRand(1000 - 1, 2, MAXN, 0);

			while (done < 25) {
				genRand(MAXN, MAXN, MAXN, 1);
			}

		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
