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

public class TestsGen implements Runnable {
	public static void main(String[] args) {
		if (args.length < 1) {
			for (I = 1; (new File(getName(I) + ".t")).exists(); I++)
				;
		} else {
			I = Integer.parseInt(args[0]);
		}
		new Thread(new TestsGen()).start();
	}

	PrintWriter out;

	Random rand = new Random(6439586L);

	static int I;

	static String getName(int i) {
		return ((i < 10) ? "0" : "") + i;
	}

	void open() {
		try {
			System.out.println("Generating test " + I);
			out = new PrintWriter(getName(I));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	void close() {
		out.close();
		I++;
	}

	final String ALPHA = "abcdefghijklmnopqrstuvwxyz";

	String randString(int len, String alpha) {
		StringBuilder ans = new StringBuilder();
		int k = alpha.length();
		for (int i = 0; i < len; i++) {
			ans.append(alpha.charAt(rand.nextInt(k)));
		}
		return ans.toString();
	}

	long rand(long l, long r) {
		return l + (rand.nextLong() >>> 1) % (r - l + 1);
	}

	int rand(int l, int r) {
		return l + rand.nextInt(r - l + 1);
	}

	void genTest(int n, int m, int l, int r, int c11, int c12, int c21, int c22) {
		if (c22 == 0) throw new Error();
		open();
		out.println(n + " " + m);
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				if (j > 0) {
					out.print(" ");
				}
				out.print(rand(l, r));
			}
			out.println();
		}
		out.println(c11 + " " + c12 + " " + c21 + " " + c22);
		close();
	}
	
	final int MAXN = 20;
	final int MAXM = 20;
	final int MAXV = 1000;
	
	public void solve() throws IOException {
		genTest(1, 1, 1, 1, 1, 1, 1, 1);
		for (int i = 0; i < 10; ++i) {
			genTest(rand(1, 4), rand(1, 4), -2, 2, rand(-1, 1), rand(-1, 1), rand(-1, 1), rand(0, 1) * 2 - 1);
		}
		for (int i = 0; i < 10; ++i) {
			genTest(rand(MAXN - 10, MAXN), rand(MAXM - 10, MAXM), -MAXV, MAXV, rand(-1, 1), rand(-1, 1), rand(-1, 1), rand(0, 1) * 2 - 1);
		}
		for (int c11 = -1; c11 <= 1; ++c11) {
			for (int c12 = -1; c12 <= 1; ++c12) {
				for (int c21 = -1; c21 <= 1; ++c21) {
					for (int c22 = -1; c22 <= 1; c22 += 2) {
						genTest(MAXM, MAXM, -MAXV, MAXV, c11, c12, c21, c22);
					}
				}
			}
		}
		genTest(MAXN, MAXM, 0, 0, 1, 1, 1, -1);
		genTest(MAXN, MAXM, MAXV, MAXV, -1, -1, -1, 1);
		genTest(MAXN, MAXM, -MAXV, -MAXV, 1, 1, 1, -1);
	}

	void myAssert(boolean e) {
		if (!e) {
			throw new Error("Assertion failed");
		}
	}

	public void run() {
		try {
			solve();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}
}