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

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

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	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());
	}

	int tNumber;

	Random rnd;

	void print(int n, int m, int i1, int j1, int i2, int j2) throws IOException {
		if (tNumber < 10) {
			out = new PrintWriter("../tests/0" + tNumber);
		} else {
				out = new PrintWriter("../tests/" + tNumber);
		}
		tNumber++;
		out.println(n + " " + m);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if ((i == i1 && j == j1) || (i == i2 && j == j2)) out.print("1" + (j == m - 1 ? "\n" : " "));
				else out.print("0" + (j == m - 1 ? "\n" : " "));
			}
		}	
		out.close();
	}

	void genSimple() throws IOException {
		PrintWriter out;
		out = new PrintWriter("../preliminary/01");
		out.println("3 4");
		out.println("0 1 0 0");
		out.println("0 0 0 0");
		out.println("0 0 0 1");
		out.close();
	}

	public void gen10() throws IOException {
	 	int[] n = {2, 2, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7, 10, 10, 10};
	 	int[] m = {2, 2, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7};
	 	
	 	int[] i1 = {0, 0, 1, 5, 6, 8, 7, 5, 0, 3, 5, 4, 7, 8, 9};
	 	int[] j1 = {0, 1, 7, 9, 7, 5, 4, 0, 0, 7, 8, 9, 3, 5, 4};
	
	 	int[] i2 = {1, 0, 5, 5, 5, 5, 5, 5, 9, 0, 1, 6, 9, 8, 7};
	 	int[] j2 = {1, 0, 5, 5, 5, 5, 5, 5, 9, 9, 8, 7, 0, 1, 6};
	 	for (int test = 0; test < i1.length; test++) {
	 		print(n[test], m[test], i1[test], j1[test], i2[test], j2[test]);
	 	}	  
	}

	public void gen70() throws IOException {
	 	int[] n = {70, 70, 70, 70};
	 	int[] m = {70, 70, 70, 70};
	 	
	 	int[] i1 = {0, 0, 0, 0};
	 	int[] j1 = {0, 69, 0, 69};
	
	 	int[] i2 = {69, 69, 69, 69};
	 	int[] j2 = {69, 0, 0, 69};
	 	for (int test = 0; test < i1.length; test++) {
	 		print(n[test], m[test], i1[test], j1[test], i2[test], j2[test]);
	 	}	  
	 	for (int test = 0; test < 15 - i1.length; test++) {
	 		int nn = rnd.nextInt(20) + 50;
	 		int mm = rnd.nextInt(20) + 50;
	 		int qi1 = rnd.nextInt(nn);
	 		int qi2 = rnd.nextInt(nn);
	 		int qj1 = rnd.nextInt(mm);
	 		int qj2 = rnd.nextInt(mm);
	 		while (qi1 == qi2 && qj1 == qj2) {
	 		 qi2 = rnd.nextInt(nn);
	 		 qj2 = rnd.nextInt(mm);
	 		}
	 		print(nn, mm, qi1, qj1, qi2, qj2); //It is a bad influence of my teammate :(
	 	}
	}

	public void genMax() throws IOException {
		int[] n = {1000, 1000, 1000, 1000};
	 	int[] m = {1000, 1000, 1000, 1000};
	 	
	 	int[] i1 = {0, 0, 0, 0};
	 	int[] j1 = {0, 999, 0, 999};
	
	 	int[] i2 = {999,999,999,999};
	 	int[] j2 = {999, 0, 0, 999};
	 	for (int test = 0; test < i1.length; test++) {
	 		print(n[test], m[test], i1[test], j1[test], i2[test], j2[test]);
	 	}	  
	 	for (int test = 0; test < 20 - i1.length; test++) {
	  		int nn = rnd.nextInt(100) + 900;
	 		int mm = rnd.nextInt(100) + 900;
	 		int qi1 = rnd.nextInt(nn);
	 		int qi2 = rnd.nextInt(nn);
	 		int qj1 = rnd.nextInt(mm);
	 		int qj2 = rnd.nextInt(mm);
	 		while (qi1 == qi2 && qj1 == qj2) {
	 		 qi2 = rnd.nextInt(nn);
	 		 qj2 = rnd.nextInt(mm);
	 		}
	 		print(nn, mm, qi1, qj1, qi2, qj2); 
	 	}
	}



	public void generate() throws IOException {
		new File("../preliminary").mkdir();
		new File("../tests").mkdir();
		tNumber = 1;
		rnd = new Random(31313131);
		genSimple();
		gen10();
		gen70();
		genMax();
	}

	public void run() throws IOException {
			generate();
	}
}