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

public class Gen {

	static int done = 0;

	static final Random rand = new Random(556668949239L);

	static final int maxN = 1500;

	long gcd(long x, long y) {
		return x == 0 ? y : gcd(y % x, x);
	}

	class Point implements Comparable<Point> {
		long x, y;

		public Point(long x, long y) {
			super();
			long g = gcd(x, y);
			x /= g;
			y /= g;
			this.x = x;
			this.y = y;
		}

		Point middle(Point other) {
			long xx = x * other.y + other.x * y;
			long yy = y * other.y * 2;
			return new Point(xx, yy);
		}

		@Override
		public int compareTo(Point o) {
			if (o.x == x)
				return Long.compare(y, o.y);
			return Long.compare(x, o.x);
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			final Point other = (Point) obj;
			if (x != other.x || y != other.y)
				return false;
			return true;
		}
	}

	static ArrayList<Point> data;

	static void print() throws IOException {
		done++;
		System.err.println(done);
		PrintWriter out = new PrintWriter(String.format("../tests/%02d", done));

		out.println(data.size());
		for (int i = 0; i < data.size(); i++)
			out.println(data.get(i).x + " " + data.get(i).y);

		data.clear();

		out.close();
	}

	void genSample1() {
		data.add(new Point(0, 1));
		data.add(new Point(1, 4));
		data.add(new Point(2, 4));
		data.add(new Point(3, 3));

	}

	void genSample2() {
		data.add(new Point(0, 2));
		data.add(new Point(1, 4));
		data.add(new Point(3, 4));
		data.add(new Point(4, 4));
	}

	void genSample3() {
		data.add(new Point(5, 8));
		data.add(new Point(1, 4));
		data.add(new Point(1, 2));
		data.add(new Point(4, 4));
		data.add(new Point(0, 4));
	}


	void genTest1() {
		data.add(new Point(0, 1));
		data.add(new Point(1, 3));
		data.add(new Point(2, 3));
		data.add(new Point(3, 3));
	}

	void genTest(int sumN) {
		Set<Point> pointsSet = new TreeSet<Point>();
		ArrayList<Point> pointsArray = new ArrayList<Point>();
		int n = 2;
		pointsSet.add(new Point(0L, 1L));
		pointsSet.add(new Point(1L, 1L));
		pointsArray.add(new Point(0L, 1L));
		pointsArray.add(new Point(1L, 1L));
		while (n != sumN) {
			Point first = pointsArray.get(rand.nextInt(pointsArray.size()));
			Point second = pointsArray.get(rand.nextInt(pointsArray.size()));
			Point newPoint = first.middle(second);
			if (newPoint.y >= 1e9)
				continue;
			if (!pointsSet.contains(newPoint)) {
				pointsSet.add(newPoint);
				pointsArray.add(newPoint);
				n++;
			}
		}
		boolean answerYes = rand.nextBoolean();
		if (!answerYes) {
			Point cantGet = pointsArray.get(pointsArray.size() - 1);
			ArrayList<Point> tmp = new ArrayList<Point>();
			for (int i = 0; i < pointsArray.size(); i++) {
				boolean add = true;
				for (int j = 0; j < tmp.size(); j++) {
					Point middle = tmp.get(j).middle(pointsArray.get(i));
					if (middle.equals(cantGet)) {
						add = false;
						break;
					}
				}
				if (add) {
					tmp.add(pointsArray.get(i));
				}
			}
			pointsArray = tmp;
		}
		data = randomShuffle(pointsArray);
	}

	ArrayList<Point> randomShuffle(ArrayList<Point> data) {
		Point[] ans = new Point[data.size()];
		for (int i = 0; i < ans.length; i++)
			ans[i] = data.get(i);
		for (int i = 0; i < ans.length; i++) {
			int ch = rand.nextInt(i + 1);
			Point tmp = ans[ch];
			ans[ch] = ans[i];
			ans[i] = tmp;
		}
		ArrayList<Point> res = new ArrayList<Gen.Point>();
		for (int i = 0; i < ans.length; i++)
			res.add(ans[i]);
		return res;
	}
	
	void genPreliminary() throws IOException {
		PrintWriter out = new PrintWriter(String.format("../preliminary/%02d",
				1));
		genSample1();
		out.println(data.size());
		for (int i = 0; i < data.size(); i++)
			out.println(data.get(i).x + " " + data.get(i).y);

		data.clear();
		out.close();

		out = new PrintWriter(String.format("../preliminary/%02d", 2));
		genSample2();
		out.println(data.size());
		for (int i = 0; i < data.size(); i++)
			out.println(data.get(i).x + " " + data.get(i).y);

		data.clear();
		out.close();

		out = new PrintWriter(String.format("../preliminary/%02d", 3));
		genSample3();
		out.println(data.size());
		for (int i = 0; i < data.size(); i++)
			out.println(data.get(i).x + " " + data.get(i).y);

		data.clear();
		out.close();
	}

	public void run() throws IOException {
		data = new ArrayList<Point>();
		
		new File("../preliminary").mkdir();
		new File("../tests").mkdir();

		genPreliminary();

		done = 0;
		

		genTest1();
		print();

		for (int i = 0; i < 19; i++) {
			genTest(400);
			print();
		}

		for (int i = 0; i < 30; i++) {
			genTest(maxN);
			print();
		}

	}

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