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;
	final int MAXN = 100000;
	ArrayList<Integer> test;
	int gcd(long a, long b) {
		if (a < 0 ||  b < 0) {
			System.err.println(a + " " + b);
			System.exit(1);
		}
		if (a > b) return(gcd(b,a));
		if (a == 0) {
			return (int) b;
		}
		return gcd(b % a, a);
	}
	
	void print(ArrayList al) throws IOException {
		System.err.println(tNumber);
		if (tNumber < 10) {
			out = new PrintWriter("../tests/0" + tNumber);
		} else {
			out = new PrintWriter("../tests/" + tNumber);
		}
		tNumber++;
		out.println(al.size() / 2);
		for (int i = 0; i < al.size() / 2; i++) {
			out.println(al.get(2 * i) + " " + al.get(2 * i + 1));
		}
		out.close();
	}
	
	void genYes(int n) throws IOException {
		int pow = (1 << n);
		long a = 0, b = 0;
		do {
			int gcd = rnd.nextInt(1000000) + 1;
			do {
				a = rnd.nextInt(pow) + 1;
				b = pow - a;
			} while (gcd(a, b) != 1);
			a *= gcd;
			b *= gcd;
		} while (a <= 0 || a > 1000000000 || b <= 0 || b > 1000000000);
		print(a, b);
	}
	
	void genNo1(int n) throws IOException {
		int pow = (1 << n);
		long a = 0, b = 0;
		do {
			int gcd = rnd.nextInt(1000000) + 1;
			do {
				a = rnd.nextInt(pow - 1) + 1;
				b = pow - a;
			} while (gcd(a, b) != 1);
			a *= gcd;
			b *= gcd;
		} while (a <= 0 || a > 1000000000 || b <= 0 || b > 1000000000);
		print(a, b);
	}

	void print(long a, long b) {
		test.add((int) a);
		test.add((int) b);
	}
	
	void genNo2(int n) throws IOException {
		int pow = (1 << n);
		long a = 0, b = 0;
		do {
			int gcd = rnd.nextInt(1000000) + 1;
			do {
				a = rnd.nextInt(pow - 1) + 1;
				b = pow - a;
			} while (gcd(a, b) != 1);
			a *= (3 * gcd);
			b *= gcd;
		} while (a <= 0 || a > 1000000000 || b <= 0 || b > 1000000000);
		print(a, b);
	}
	
	void genNo3(int n) throws IOException {
		int pow = (1 << n);
		long a = 0, b = 0;
		do {
			int gcd = rnd.nextInt(1000000) + 1;
			do {
				a = rnd.nextInt(pow - 1) + 1;
				b = pow - a;
			} while (gcd(a, b) != 1);
			a *= (2 * gcd);
			b *= gcd;
		} while (a <= 0 || a > 1000000000 || b <= 0 || b > 1000000000);
		print(a, b);
	}
	
	void genRand(int n) throws IOException {
		print(rnd.nextInt(n) + 1,rnd.nextInt(n) + 1);
	}
	
	
	String genRandomString(int len, String alph) {
		char[] a = new char[len];
		for (int i = 0; i < len; i++) {
			a[i] = alph.charAt(rnd.nextInt(alph.length()));
		}
		return new String(a);
	}

	void genSimple() throws IOException {
		ArrayList<Integer> al = new ArrayList<Integer>();
		al.add(2);
		al.add(6);
		al.add(1);
		al.add(5);
		al.add(4);
		al.add(4);
		print(al);
		print(8, 12);
		print(1, 1);
		print(1, 2);
		print(1, 3);
		print(7, 9);
	}

	public void generate() throws IOException {
		new File("../tests").mkdir();
		tNumber = 1;
		test = new ArrayList<Integer>();
		genSimple();
		rnd = new Random(3131313);
		for (int i = 0; i < 25; i++) {
			genRand(50);
		}
		for (int i = 1; i < 31; i++) {
			genYes(i);
		}
		for (int i = 0; i < 3; i++) {
			genNo1(rnd.nextInt(30) + 1);
			genNo2(rnd.nextInt(30) + 1);
			genNo3(rnd.nextInt(30) + 1);
		}
		for (int i = 0; i < 7; i++) {
			genRand(1000000000);
		}
		for (int i = 0; i < 10000; i++) {
			genRand(50);
		}
		System.err.println("Working...");
		for (int i = 0; i < 100; i++) {
			genNo1(rnd.nextInt(30) + 1);
			genNo2(rnd.nextInt(30) + 1);
			genNo3(rnd.nextInt(30) + 1);
		}
		System.err.println("Don't panic! Working...");
		for (int j = 0; j < 200; j++) {
        	for (int i = 1; i < 31; i++) {
			genYes(i);
		}
	        }
		System.err.println("Don't panic! :) Working...");
		print(1, (1 << 29) - 1);
		print((1 << 29), 1);
		print(1000000000, 1000000000);
		
		while (test.size() != 99999 * 2) {
			genRand(1000000000);
		}
		print(test);
	}

	public void run() throws IOException {
		Locale.setDefault(Locale.US);
		generate();
	}
}