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

public class StressGen {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.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());
	}

	public void solve() throws IOException {
		Random rnd = new Random();
		int n = 5 + rnd.nextInt(6);
		int m = 5 + rnd.nextInt(6);
		out.println(n + " "+ m);
		int[][] a = new int[n][m];
		int i1 = rnd.nextInt(n);
		int j1 = rnd.nextInt(m);
		int i2 = rnd.nextInt(n);
		int j2 = rnd.nextInt(m);
		while (i2 == i1 && j2 == j1) {
		 i2 = rnd.nextInt(n);
		j2 = rnd.nextInt(m);
		}
		a[i1][j1] = 1;
		a[i2][j2] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				out.print(a[i][j] + ((j == m - 1) ? "\n" : " "));
			}
		}	


	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			//br = new BufferedReader(new FileReader("StressGen.in"));
			out = new PrintWriter("garnett.in");

			solve();

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

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