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

public class TestsGen {

	static Random rand = new Random(256346);

	static int testsCount = 0;

	static int[] magic = new int[] { 1, 5, 25, 65, 325, 1105, 4225, 5525,
			27625, 71825, 138125, 160225, 801125, 2082925, 4005625, 5928325,
			29641625, 77068225, 148208125, 243061325, 1215306625 };
	static int[] size = new int[] { 4, 12, 20, 36, 60, 108, 100,
			180, 252, 300, 324, 540, 756, 900, 972, 1620, 2268, 2700, 2916,
			4860, 6804 };
	
	static int MAX = 1000000;
	
	static void write(PrintWriter out, int[] x, int[] y) {
		System.out.println(testsCount);
		out.println(x.length);
		for (int i = 0; i < x.length; i++) {
			out.println(x[i] + " " + y[i]);
		}
		out.close();
	}

	static int[] xPr1 = new int[] { 1, 0, 1, 3, 3, 2, 4 };
	static int[] yPr1 = new int[] { -1, 0, 1, 1, -1, 0, 0 };
	static int[] xPr2 = new int[] { -1000000, 0, 1000000, 0, 0 };
	static int[] yPr2 = new int[] { 0, 1000000, 0, -1000000, 0 };

	static void genPreliminary() throws IOException {
		write(new PrintWriter("../preliminary/01"), xPr1, yPr1);
		write(new PrintWriter("../preliminary/02"), xPr2, yPr2);
	}
	
	class Pair {
		private int x, y;
		
		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		@Override
		public boolean equals(Object o) {
			Pair p = (Pair) o;
			return p.x == x && p.y == y;
		}
		
		@Override
		public int hashCode() {
			return 239017 * x + y;
		}
	}
	
	int countDiff(int[] x, int[] y) {
		Set<Pair> p = new HashSet<Pair>();
		int n = x.length;
		int[] rx = new int[n];
		int[] ry = new int[n];
		int k = 0;
		for (int i = 0; i < n; i++) {
			Pair pp = new Pair(x[i], y[i]);
			if (!p.contains(pp)) {
				rx[k] = x[i];
				ry[k] = y[i];
				k++;
				p.add(pp);
			}
		}
		for (int i = 0; i < n; i++) {
			x[i] = rx[i];
			y[i] = ry[i];
		}
		return k;
	}

	void write(Circle a, Circle b, double shuffle) {
		int n = a.x.length + b.x.length;
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < a.x.length; i++) {
			x[i] = a.x[i];
			y[i] = a.y[i];
		}
		for (int i = a.x.length; i < n; i++) {
			x[i] = b.x[i - a.x.length];
			y[i] = b.y[i - a.x.length];
		}
		if (shuffle < 0) {
			int t = x[0]; x[0] = x[x.length - 1]; x[x.length - 1] = t;
			t = y[0]; y[0] = y[y.length - 1]; y[y.length - 1] = t;
		}
		for (int count = 0; count < (shuffle == -1 ? 0 : Math.abs(shuffle) * n); count++) {
			int t = shuffle < 0 ? n - 2 : n; 
			int i = rand.nextInt(t);
			int j = rand.nextInt(t);
			if (shuffle < 0) {
				i++; j++;
			}
			t = x[i]; x[i] = x[j]; x[j] = t;
			t = y[i]; y[i] = y[j]; y[j] = t;
		}
		int cntdiff = countDiff(x, y);
		x = Arrays.copyOf(x, cntdiff);
		y = Arrays.copyOf(y, cntdiff);
		try {
			TestsGen.write(
					new PrintWriter(String
							.format("../tests/%02d", ++testsCount)), x, y);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	static class Circle {
		int[] x, y;
		
		static Circle createCircle(long r, boolean sqrflag, boolean shuffle, int size, int shift) {
			Circle ret = null;
			if (sqrflag) {
				ret = new Circle(r, true);
			} else {
				ret = new Circle(r);
			}
			if (shuffle) {
				ret = ret.shuffle();
			}
			if (size > 0) {
				ret = ret.filterRand(size);
			}
			if (shift > 0) {
				ret = ret.randShift(shift);
			}
			return ret;
		}

		private int[] toArray(ArrayList<Long> al) {
			int[] ret = new int[al.size()];
			for (int i = 0; i < ret.length; i++) {
				ret[i] = al.get(i).intValue();
			}
			return ret;
		}
		
		Circle(long r, boolean sqrtflag) {
			ArrayList<Long> alx = new ArrayList<Long>();
			ArrayList<Long> aly = new ArrayList<Long>();
			for (long i = 0; i * i < r; i++) {
				long j = r - i * i;
				long sqrtj = Math.round(Math.sqrt(j));
				if (sqrtj * sqrtj == j) {
					alx.add(i);
					aly.add(sqrtj);
					alx.add(-sqrtj);
					aly.add(i);
					alx.add(-i);
					aly.add(-sqrtj);
					alx.add(sqrtj);
					aly.add(-i);
				}
			}
			x = toArray(alx);
			y = toArray(aly);
		}

		Circle(long r) {
			ArrayList<Long> alx = new ArrayList<Long>();
			ArrayList<Long> aly = new ArrayList<Long>();
			for (long i = 0; i < r; i++) {
				long j = r * r - i * i;
				long sqrtj = Math.round(Math.sqrt(j));
				if (sqrtj * sqrtj == j) {
					alx.add(i);
					aly.add(sqrtj);
					alx.add(-sqrtj);
					aly.add(i);
					alx.add(-i);
					aly.add(-sqrtj);
					alx.add(sqrtj);
					aly.add(-i);
				}
			}
			x = toArray(alx);
			y = toArray(aly);
		}

		int size() {
			return x.length;
		}
		
		Circle shuffle() {
			for (int i = 0; i < x.length; i++) {
				int j = rand.nextInt(i + 1);
				int t = x[i]; x[i] = x[j]; x[j] = t;
				t = y[i]; y[i] = y[j]; y[j] = t;
			}
			return this;
		}
		
		Circle filterRand(int size) {
			int n = x.length;
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			for (int i = 0; i < n; i++) {
				int j = rand.nextInt(i + 1);
				int t = p[i];
				p[i] = p[j];
				p[j] = t;
			}
			int[] nx = new int[size];
			int[] ny = new int[size];
			for (int i = 0; i < size; i++) {
				nx[i] = x[p[i]];
				ny[i] = y[p[i]];
			}
			x = nx;
			y = ny;
			return this;
		}

		Circle shift(int dx, int dy) {
			for (int i = 0; i < x.length; i++) {
				x[i] = x[i] + dx;
				y[i] = y[i] + dy;
			}
			return this;
		}
		
		Circle randShift(int MAX) {
			int minx = Integer.MAX_VALUE;
			int maxx = Integer.MIN_VALUE;
			for (int i = 0; i < x.length; i++) {
				minx = Math.min(minx, x[i]);
				maxx = Math.max(maxx, x[i]);
			}
			int fx = Math.max(2 * MAX - (maxx - minx), 0);
			if (fx == 0) {
				return this;
			}
			int dx = rand.nextInt(fx) - minx - MAX;
			int miny = Integer.MAX_VALUE;
			int maxy = Integer.MIN_VALUE;
			for (int i = 0; i < x.length; i++) {
				miny = Math.min(miny, y[i]);
				maxy = Math.max(maxy, y[i]);
			}
			int fy = 2 * MAX - (maxy - miny);
			int dy = rand.nextInt(fy) - miny - MAX;
			return shift(dx, dy);
		}
	}

	public static void main(String[] args) throws IOException {
		new File("../preliminary").mkdir();
		new File("../tests").mkdir();

		genPreliminary();

		new TestsGen().genMain();

	}
	
	void write2() {
		try {
			TestsGen.write(
					new PrintWriter(String
							.format("../tests/%02d", ++testsCount)), new int[]{1, -1}, new int[]{2, 1});
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	void write3() {
		try {
			TestsGen.write(
					new PrintWriter(String
							.format("../tests/%02d", ++testsCount)), new int[]{1, -1, 0}, new int[]{2, 0, 1});
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	void write4() {
		try {
			TestsGen.write(
					new PrintWriter(String
							.format("../tests/%02d", ++testsCount)), new int[]{-3, 0, 6, -12}, new int[]{-2, 0, 4, -8});
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	void genMain() {
		write2();
		write3();
		write4();
		write(Circle.createCircle(1, false, true, 3, 3), Circle.createCircle(1, false, true, 0, 3), 0);
		write(Circle.createCircle(5, false, true, 5, 10), Circle.createCircle(50, true, true, 10, 10), 1.0);
		write(Circle.createCircle(85, true, true, 11, 10), Circle.createCircle(97, true, true, 3, 10), 3.0);
		write(Circle.createCircle(81, true, true, 2, 100), Circle.createCircle(61, true, true, 5, 100), 1.5);
		write(Circle.createCircle(magic[12], false, true, 25, MAX), Circle.createCircle(magic[11], false, true, 25, MAX), -1);
		write(Circle.createCircle(3396770, true, true, 15, MAX), Circle.createCircle(5663125, true, true, 15, MAX), 3);
		write(Circle.createCircle(1, false, true, 1, 0), Circle.createCircle(5000125, true, true, 49, 0), 0);
		
		write(Circle.createCircle(magic[12], false, true, 0, MAX), Circle.createCircle(magic[12], false, true, 0, MAX), 0);
		write(Circle.createCircle(magic[12], false, true, 0, MAX), Circle.createCircle(magic[12], false, true, 0, MAX), 1.0);
		write(Circle.createCircle(magic[12], false, true, 0, MAX), Circle.createCircle(magic[12], false, true, 0, MAX), -1);
		write(Circle.createCircle(243061325, true, true, 0, MAX), Circle.createCircle(994196125, true, true, 0, MAX), -1);
		write(Circle.createCircle(magic[11], false, true, 0, MAX / 10), Circle.createCircle(magic[12], false, true, size[12] / 2, MAX / 10), -1);
		write(Circle.createCircle(magic[11], false, false, 2 * size[11] / 3, MAX / 100), Circle.createCircle(704244125, true, true, 0, MAX / 100), -1);
		write(Circle.createCircle(magic[10], false, true, size[10] - 3, MAX), Circle.createCircle(magic[9], false, true, 3, MAX), -1);
		write(Circle.createCircle(magic[12], false, true, size[12] / 3, MAX / 10), Circle.createCircle(270863125, true, true, 101, MAX / 5), -1);
		write(Circle.createCircle(magic[12], false, true, size[12], magic[12] + 3), Circle.createCircle(magic[12], false, true, size[12], magic[12] + 3), -1);
		write(Circle.createCircle(magic[12], false, true, size[12] / 4, magic[12] + 100), Circle.createCircle(2082925, true, true, 100, 10000), -1);
//		write(new Circle(1), new Circle(1).shift(1, 0), 0);
//		write(new Circle(243061325), new Circle(243061325).shift(10, -1000), 0);
	}
}