// Tests generator for Bloxx problem
// Author : Vladimir Ulyantsev, ulyantsev@rain.ifmo.ru

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

public class BloxxTestsGen 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 BloxxTestsGen()).start();
    }

    PrintWriter out;

    Random random = new Random(6466403L);

    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 int MAXN = 10;
    final int MAXP = 16;
    final int MAXH = 5;


    void gen(int n, int m, int r) {
    	open();
    	
    	out.println(n + " " + m);
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < m; j++) {
    			if (j > 0)
    				out.print(" ");
    			boolean isZero = random.nextInt(r) == 0;
    			out.print(isZero ? 0 : random.nextInt(MAXH) + 1);
    		}
    		out.println();
    	}

    	close();
    }

    public void solve() throws IOException {
    	for (int i = 1; i <= MAXN; i++) {
    		for (int j = 1; j < MAXN; j++) {
    			if (i * j <= MAXP) {
    				gen(i, j, 1);
				}
			}
		}

    	for (int i = 3; i <= MAXN; i++) {
    		for (int j = 3; j < MAXN; j++) {
    			if (i * j <= MAXP) {
    				gen(i, j, 2);
				}
			}
		}


    	for (int i = 3; i <= MAXN; i++) {
    		for (int j = 3; j < MAXN; j++) {
    			if (i * j <= MAXP) {
    				gen(i, j, 5);
				}
			}
		}


    	for (int i = 3; i <= MAXN; i++) {
    		for (int j = 3; j < MAXN; j++) {
    			if (i * j <= MAXP) {
    				gen(i, j, 1000000);
				}
			}
		}


    }

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