import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class TestsGen {
	static int testcount = 0;

	static Random random = new Random(8345258);
	
	static int MAXNM = 50;
	static int MAXK = 10000;
	
	static void write(int n, int m, int k) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		out.println(n + " " + m + " " + k);
		out.close();
	}

	static void writeMax(int n, int m) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		out.println(n + " " + m + " " + Math.min(maxans(n, m), MAXK));
		out.close();
	}

	static void writeMin(int n, int m) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		out.println(n + " " + m + " " + Math.min(maxans(n, m) + 1, MAXK));
		out.close();
	}

	public static void main(String[] args) throws IOException {
		while (new File(String.format("%02d.t", testcount + 1)).exists()) {
			testcount++;
		}
		System.out.println(BigInteger.valueOf(331).isProbablePrime(100));
		write(1, 1, 1);
		write(1, 1, MAXK);
		writeMax(1, 2);
		writeMin(2, 1);
		writeMin(1, 3);
		writeMax(3, 1);
		write(2, 2, 1);
		writeMax(2, 2);
		writeMin(2, 2);
		writeMax(4, 4);
		writeMin(4, 4);
		writeMax(1, MAXNM);
		writeMax(MAXNM, 1);
		writeMin(1, MAXNM);
		writeMin(MAXNM, 1);
		writeMax(2, MAXNM);
		writeMin(2, MAXNM);
		writeMax(MAXNM, 2);
		writeMin(MAXNM, 2);
		for (int i = 1; i <= 3; i++) {
			write(i, random.nextInt(50) + 1, random.nextInt(i * 50) + 1);
			write(random.nextInt(50) + 1, i, random.nextInt(i * 50) + 1);
			writeMax(i, random.nextInt(10) + 1);
			writeMax(random.nextInt(10) + 1, i);
			writeMin(i, random.nextInt(10) + 1);
			writeMin(random.nextInt(10) + 1, i);
		}
		writeMax(31, 32);
		writeMin(31, 32);
		writeMax(32, 31);
		writeMin(32, 31);
		write(MAXNM, MAXNM, 1);
		writeMax(MAXNM, MAXNM);
		writeMin(MAXNM, MAXNM);
		write(MAXNM, MAXNM, MAXK);
		for (int i = 0; i < 10; i++) {
			write(random.nextInt(MAXNM) + 1, random.nextInt(MAXNM) + 1, random.nextInt(MAXK) + 1);
			writeMax(random.nextInt(MAXNM) + 1, random.nextInt(MAXNM) + 1);
			writeMin(random.nextInt(MAXNM) + 1, random.nextInt(MAXNM) + 1);
		}
	}

	static int maxans(int n, int m) {
		char[][] ans = new char[n][m];
		for (char[] cs : ans) {
			Arrays.fill(cs, '.');
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (i % 3 == 1 && j % 3 == 1) {
					ans[i][j] = 'T';
				}
			}
		}
		if (n % 3 == 1) {
			for (int j = 0; j < m; j++) {
				if (j % 3 == 1) {
					ans[n - 1][j] = 'T';
				}
			}
		}
		if (m % 3 == 1) {
			for (int i = 0; i < n; i++) {
				if (i % 3 == 1) {
					ans[i][m - 1] = 'T';
				}
			}
		}
		if (n % 3 == 1 && m % 3 == 1) {
			ans[n - 1][m - 1] = 'T';
		}
		int ret = 0;
		for (char[] cs : ans) {
			for (char c : cs) {
				if (c == '.') {
					ret++;
				}
			}
		}
		return ret;
	}
}
