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

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

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;
	int TNumber;
	Random rnd;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	ArrayList<Integer> generateGoodString(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n / 2; i++) {
			a[i] = rnd.nextInt(2);
		}
		for (int i = n / 2; i < n / 2 * 2; i++) {
			a[i] = a[n / 2 * 2 - i - 1];
		}
		if (n % 2 == 1)
			a[n - 1] = rnd.nextInt(2);
		ArrayList<Integer> res = new ArrayList<Integer>();
		if ((n % 2 == 0) && (rnd.nextInt(3) > 0)) {
			a[0] = rnd.nextInt(2);
			for (int i = 1; i < n / 2; i++) {
				a[i] = rnd.nextInt(2);
			}
			for (int i = n / 2 + 1; i < n; i++) {
				a[i] = a[n - i];
			}
		}
		int t = rnd.nextInt(n);
		for (int i = 0; i < n; i++) {
			res.add(a[(t + i) % n]);
		}
		return res;
	}

	ArrayList<Integer> generateRandString(int n) {
		ArrayList<Integer> res = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			res.add(rnd.nextInt(2));
		}
		return res;
	}

	ArrayList<Integer> generateGoodStringWithBugs(int n, int k) {
		ArrayList<Integer> res = generateGoodString(n);
		for (int i = 0; i < k; i++) {
			int t = rnd.nextInt(n);
			res.set(t, 1 - res.get(t));
		}
		return res;
	}

	ArrayList<Integer> generateInterestingString() {
		int t = rnd.nextInt(3);
		ArrayList<Integer> res = new ArrayList<Integer>();
		if (t == 0)
			for (int i = 0; i < 100000; i++) {
				res.add(i % 2);
			}
		if (t == 1)
			for (int i = 0; i < 100000; i++) {
				res.add(0);
			}
		if (t == 2)
			for (int i = 0; i < 100000; i++) {
				res.add(1);
			}
		for (int i = 0; i < 4; i++) {
			t = rnd.nextInt(100000);
			res.set(t, 1 - res.get(t));
		}
		return res;
	}

	class Test {
		int T;
		ArrayList<Integer>[] a;

		void printTest() throws IOException {
			if (TNumber < 10)
				out = new PrintWriter("0" + TNumber);
			else
				out = new PrintWriter("" + TNumber);
			TNumber++;
			out.println(T);
			for (int i = 0; i < T; i++) {
				out.println(a[i].size());
				for (int j = 0; j < a[i].size(); j++) {
					out.print(a[i].get(j));
					if (j < a[i].size() - 1)
						out.print(" ");
					else
						out.println();
				}
			}
			out.close();
		}

		void addString(ArrayList<Integer> s) {
			a[T] = s;
			T++;
		}

		void reset() {
			T = 0;
			a = new ArrayList[10];
		}

		void genOneStandardTest(int minLength, int diffLength, int minBugs,
				int diffBugs) throws IOException {
			reset();
			for (int i = 0; i < 10; i++) {
				int t = rnd.nextInt(3);
				if (t == 0)
					addString(generateGoodString(rnd.nextInt(diffLength)
							+ minLength));
				if (t == 1)
					addString(generateRandString(rnd.nextInt(diffLength)
							+ minLength));
				if (t == 2)
					addString(generateGoodStringWithBugs(
							rnd.nextInt(diffLength) + minLength,
							rnd.nextInt(diffBugs) + minBugs));
				if ((i == 9) && (TNumber > 15))
					a[i] = generateInterestingString();
			}
			printTest();
		}

		void genFirstTest() throws IOException {
			reset();
			T = 5;
			for (int i = 0; i < 4; i++) {
				a[i] = new ArrayList<Integer>();
				a[i].add(i / 2);
				a[i].add(i % 2);
			}
			a[4] = generateRandString(9);
			printTest();
		}

		void genSecondTest() throws IOException {
			reset();
			T = 9;
			for (int i = 0; i < 8; i++) {
				a[i] = new ArrayList<Integer>();
				a[i].add(i % 2);
				a[i].add(i / 2 % 2);
				a[i].add(i / 4);
			}
			a[8] = generateRandString(9);
			printTest();
		}
	}

	public void solve() throws IOException {
		rnd = new Random(7531);
		TNumber = 1;
		Test a = new Test();

		a.genFirstTest();
		a.genSecondTest();

		a.genOneStandardTest(5, 10, 1, 1);
		a.genOneStandardTest(5, 10, 1, 3);
		a.genOneStandardTest(5, 10, 2, 5);

		a.genOneStandardTest(400, 200, 1, 1);
		a.genOneStandardTest(400, 200, 50, 50);

		a.genOneStandardTest(1000, 1, 1, 5);
		a.genOneStandardTest(1000, 1, 10, 30);
		a.genOneStandardTest(1000, 1, 100, 50);

		a.genOneStandardTest(10000, 2000, 1, 1);
		a.genOneStandardTest(10000, 2000, 10, 15);
		a.genOneStandardTest(10000, 2000, 50, 50);

		a.genOneStandardTest(20000, 20000, 1, 1);
		a.genOneStandardTest(20000, 20000, 10, 15);
		a.genOneStandardTest(20000, 10000, 50, 50);

		a.genOneStandardTest(40000, 20000, 1, 1);
		a.genOneStandardTest(40000, 20000, 10, 15);
		a.genOneStandardTest(40000, 20000, 50, 50);

		a.genOneStandardTest(60000, 20000, 1, 1);
		a.genOneStandardTest(60000, 20000, 10, 15);
		a.genOneStandardTest(60000, 20000, 50, 50);

		a.genOneStandardTest(100000, 1, 1, 1);
		a.genOneStandardTest(100000, 1, 10, 15);
		a.genOneStandardTest(100000, 1, 50, 50);

	}

	public void run() {
		try {

			solve();

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