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

public class TestGen {

	PrintWriter out;
	Random rnd;
	int tNumber;

	class Job {
		int d, w;

		public Job(int d, int w) {
			this.d = d;
			this.w = w;
		}

		@Override
		public String toString() {
			return w + " " + d;
		}

	}

	class Test {
		ArrayList<Job> jobs = new ArrayList<TestGen.Job>();

		void init() {
			jobs = new ArrayList<TestGen.Job>();
		}

		void printTest() {
			try {
				if (tNumber < 10)
					out = new PrintWriter("../tests/0" + tNumber);
				else
					out = new PrintWriter("../tests/" + tNumber);
			} catch (IOException e) {
				e.printStackTrace();
			}
			System.err.println("[" + tNumber + "]");
			tNumber++;

			Collections.shuffle(jobs, rnd);

			out.println(jobs.size());
			for (Job j : jobs) {
				out.println(j.toString());
			}

			out.close();
			init();
		}

		void genRandomTest(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(rnd.nextInt(n + 1), rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genOneAnswerTest(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(i, rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genChoiceEveryKTimesTest(int n, int maxW, int k) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(i + k - (i % k + 1), rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genZeroTest(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(0, rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genDespair(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(n, rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genOneGoodChoice(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(n - 1, rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genOneBadChoice(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(1, rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genWTFTest(int n, int maxW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(i + 1, rnd.nextInt(maxW)));
			}
			printTest();
		}

		void genLongAnswerTest(int n, int maxW, int minW) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(n, minW + rnd.nextInt(maxW - minW)));
			}
			printTest();
		}

		void genZeroRandomTest(int n, int w) {
			for (int i = 0; i < n; i++) {
				jobs.add(new Job(rnd.nextInt(n + 1), 0));
			}
			printTest();
		}

		void genScrewedTest(int n, int W, double prob, double probOfZero) {
			for (int i = 0; i < n; i++) {
				int w = rnd.nextInt(W);
				if (rnd.nextDouble() < probOfZero) {
					w = 0;
				}
				if (rnd.nextDouble() < prob) {
					jobs.add(new Job(i + 1, w));
				} else {
					jobs.add(new Job(i, w));
				}
			}
			printTest();
		}
	}

	public void solve() throws IOException {
		genSample();

		tNumber = 2;
		rnd = new Random(31);
		Test t = new Test();
		for (int i = 0; i < 10; i++) {
			t.genRandomTest(3, 3);
		}

		for (int i : new int[] { 1, 2, 5, 10, 100, 100000 }) {
			t.genChoiceEveryKTimesTest(maxN, maxW, i);
		}
		for (int curW : new int[] { 2, 3, 10, maxW }) {
			t.genDespair(maxN, curW);
			t.genLongAnswerTest(maxN, curW, curW / 2);
			t.genOneAnswerTest(maxN, curW);
			t.genOneBadChoice(maxN, curW);
			t.genOneGoodChoice(maxN, curW);
			t.genWTFTest(maxN, curW);
			t.genZeroTest(maxN, curW);
			for (double prob : new double[] { 0, 0.2, 0.5, 0.8, 1 }) {
				for (double prob2 : new double[] { 0, 0.2, 0.5, 0.8, 1 }) {
					if (rnd.nextBoolean())
						t.genScrewedTest(maxN, maxW, prob, prob2);
				}
			}
		}

	}

	int maxW = (int) (1e9 + 1);
	int maxN = (int) (1e5);

	private void genSample() throws FileNotFoundException {
		out = new PrintWriter("../tests/01");
		out.print("3\r\n5 2\r\n2 2\r\n1 1\r\n");
		out.close();
	}

	public void run() {
		try {

			solve();

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

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