import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Random;

public class gen_pinetree {
	static PrintWriter out;
	static Random rand = new Random(321);
	static int test = 0;

	static void next() {
		test++;
		if (out != null) {
			out.close();
		}
		try {
			out = new PrintWriter((test / 10) + "" + (test % 10));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		genFirstGroup();
		genSecondGroup();
		genThirdGroup();
		out.close();
	}

	private static void genFirstGroup() {
		smallestTest();
		fourTest1();
		fourTest2();
		triStar();
		strange1();
		smallHedgehog();
	}

	private static void smallestTest() {
		next();
		out.println("3");
		out.println("1 2");
		out.println("2 3");
	}

	private static void fourTest1() {
		next();
		out.println("4");
		out.println("2 1");
		out.println("1 3");
		out.println("2 4");
	}

	private static void fourTest2() {
		next();
		out.println("4");
		out.println("2 1");
		out.println("2 3");
		out.println("2 4");
	}

	private static void triStar() {
		next();
		out.println("7");
		out.println("1 2");
		out.println("1 3");
		out.println("1 4");
		out.println("2 5");
		out.println("3 6");
		out.println("4 7");
	}

	private static void strange1() {
		next();
		out.println("15");
		out.println("1 2");
		out.println("1 3");
		out.println("1 4");
		out.println("2 5");
		out.println("2 6");
		out.println("3 7");
		out.println("3 8");
		out.println("4 9");
		out.println("4 10");
		out.println("5 11");
		out.println("5 12");
		out.println("6 13");
		out.println("6 14");
		out.println("7 15");
	}

	private static void smallHedgehog() {
		next();
		out.println("15");
		for (int i = 0; i < 14; i++) {
			out.println("15 " + (i + 1));
		}
	}

	private static void genSecondGroup() {
		notSoBigStick();
		notSoBigHedgehog();
		smallBinaryTree();
		randomNotSoBigTree(false);
		randomNotSoBigTree(true);
		randomNotSoBigTree(true);
	}

	private static void notSoBigStick() {
		next();
		out.println("100");
		int[] a = randPerm(100);
		for (int i = 0; i + 1 < a.length; i++) {
			out.println((a[i] + 1) + " " + (a[i + 1] + 1));
		}
	}

	private static void notSoBigHedgehog() {
		next();
		out.println("100");
		int x = 1 + rand.nextInt(100);
		for (int i = 1; i <= 100; i++) {
			if (i != x) {
				out.println(i + " " + x);
			}
		}
	}

	private static void smallBinaryTree() {
		next();
		out.println("100");
		for (int i = 1; i <= 50; i++) {
			out.println(i + " " + (2 * i));
			if (2 * i + 1 <= 100) {
				out.println(i + " " + (2 * i + 1));
			}
		}
	}

	private static void randomNotSoBigTree(boolean veryBig) {
		next();
		int n = 50 + rand.nextInt(51);
		if (veryBig) {
			n = 100;
		}
		int[] a = new int[n];
		a[0] = -1;
		for (int i = 1; i < a.length; i++) {
			a[i] = rand.nextInt(i);
		}
		int[] perm = randPerm(n);
		out.println(n);
		for (int i = 1; i < a.length; i++) {
			out.println((perm[i] + 1) + " " + (perm[a[i]] + 1));
		}
	}

	private static int[] randPerm(int n) {
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = i;
			int j = rand.nextInt(i + 1);
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
		return a;
	}

	private static void genThirdGroup() {
		bigStick();
		bigBinaryTree();
		bigHedgehog();
		randomBigTree(false);
		randomBigTree(false);
		randomBigTree(true);
		randomBigTree(true);
		randomBigTree(true);
	}

	private static void bigStick() {
		next();
		out.println("100000");
		int[] a = randPerm(100000);
		for (int i = 0; i + 1 < a.length; i++) {
			out.println((a[i] + 1) + " " + (a[i + 1] + 1));
		}
	}

	private static void bigBinaryTree() {
		next();
		out.println("100000");
		for (int i = 1; i <= 50000; i++) {
			out.println(i + " " + (2 * i));
			if (2 * i + 1 <= 100000) {
				out.println(i + " " + (2 * i + 1));
			}
		}
	}

	private static void bigHedgehog() {
		next();
		out.println("100000");
		int x = 1 + rand.nextInt(100000);
		for (int i = 1; i <= 100000; i++) {
			if (i != x) {
				out.println(i + " " + x);
			}
		}
	}

	private static void randomBigTree(boolean veryBig) {
		next();
		int n = 50000 + rand.nextInt(50001);
		if (veryBig) {
			n = 100000;
		}
		int[] a = new int[n];
		a[0] = -1;
		for (int i = 1; i < a.length; i++) {
			a[i] = rand.nextInt(i);
		}
		int[] perm = randPerm(n);
		out.println(n);
		for (int i = 1; i < a.length; i++) {
			out.println((perm[i] + 1) + " " + (perm[a[i]] + 1));
		}
	}

}
