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

public class TestsGen {

	static String str = "../tests/";

	static TestWriter testWriter = new TestWriter(false);

	static class RodTest {
		int n;
		int[] l;
		int[] d;

		public RodTest(int[] l, int[] d) {
			this.l = l;
			this.d = d;
			n = l.length;
		}

		public String toString() {
			StringBuilder ans = new StringBuilder(n + "\r\n");
			for (int i = 0; i < n; i++) {
				ans.append(l[i] + " " + d[i] + "\r\n");
			}
			return ans.toString();
		}
	}

	static void genSample() throws IOException {
		RodTest test = new RodTest(new int[] { 2, 3 }, new int[] { 1, 1 });
		testWriter.printSimpleTest(test);
	}

	static void genRand(int n) throws IOException {
		int[] l = new int[n];
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = rnd.nextInt(2, 1000000);
			d[i] = rnd.nextInt(1, l[i]);
		}
		testWriter.printSimpleTest(new RodTest(l,d));
	}

	public static void main(String[] args) throws IOException {
		new File("../tests").mkdir();
		genSample();
		genRand(1);
		genRand(10000);
		for (int i = 0; i < 7; i++) {
			genRand(rnd.nextInt(1, 10000));
		}
		return;
	}

	static final Randomizer rnd = new Randomizer(556668949239L);

	public static class Randomizer extends Random {
		private static final long serialVersionUID = 1L;

		public Randomizer(long val) {
			super(val);
		}

		public int nextInt(int l, int r) {
			return super.nextInt(r - l + 1) + l;
		}
	}

	public static class TestWriter {
		private boolean isMultiTest;
		private int done;

		private boolean isOpened;
		private PrintWriter out;
		private int printedTests;
		private int countTests = 0;

		public TestWriter(boolean isMultiTest) {
			this.isMultiTest = isMultiTest;
			this.done = 0;
		}

		public void init(int n) throws FileNotFoundException {
			printedTests = 0;
			if (isOpened) {
				throw new AssertionError("Please close prevoius multitest");
			}
			isOpened = true;
			countTests = n;
			done++;
			out = new PrintWriter(str + ((done < 10) ? "0" : "")
					+ String.valueOf(done));
			if (isMultiTest) {
				out.println(countTests);
			}
		}

		public void close() {
			if (!isOpened) {
				System.err.println("Before closing test was not created");
			}
			isOpened = false;
			if (printedTests != countTests) {
				throw new AssertionError("Wrong number of tests: all: "
						+ countTests + " printed: " + printedTests);
			}
			out.close();
		}

		public void printTest(Object test) throws IOException {
			if (!isMultiTest) {
				throw new AssertionError("Multi test doesn't allowed");
			}
			if (!isOpened) {
				throw new AssertionError("Please create test");
			}
			printedTests++;
			out.println(test.toString());
		}

		public void printSimpleTest(Object test) throws IOException {
			init(1);
			printedTests++;
			out.print(test.toString());
			close();
		}
	}

}