import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Scanner;

public class TestGen extends Thread {

	class Pair {
		int a, b;

		public Pair(int a, int b) {
			super();
			this.a = a;
			this.b = b;
		}

	}

	class Test {
		int m, x, y;
		Pair[] p;

		public Test(int m, int x, int y, Pair[] p) {
			this.m = m;
			this.x = x;
			this.y = y;
			this.p = p;
		}

	}

	// TODO
	private int testCount = 12;

	private void write(Test t) {
		try {
			++testCount;
			String filename = testCount / 10 + "" + testCount % 10;
			PrintWriter out = new PrintWriter(filename);
			System.err.println(testCount);
			out.println(t.p.length + " " + t.m + " " + t.x + " " + t.y);
			for (int i = 0; i < t.p.length; i++) {
				out.println(t.p[i].b + " " + t.p[i].a);
			}
			out.println();
			out.flush();
			out.close();
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
	}

	void myAssert(boolean b) {
		if (!b)
			throw new AssertionError();
	}

	static Random rand = new Random(1);

	void shuffle(Object[] a) {
		for (int i = 0; i < a.length; i++) {
			int x = rand.nextInt(i + 1);
			Object o = a[x];
			a[x] = a[i];
			a[i] = o;
		}
	}
	
	int solve(Test t){
		try {
			String filename = "figure.in";
			PrintWriter out = new PrintWriter(filename);
			out.println(t.p.length + " " + t.m + " " + t.x + " " + t.y);
			for (int i = 0; i < t.p.length; i++) {
				out.println(t.p[i].b + " " + t.p[i].a);
			}
			out.println();
			out.flush();
			out.close();
			new figure_sm().run();
			Scanner in = new Scanner(new File("figure.out"));
			int x = in.nextInt();
			in.close();
			return x;
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
	}

	Test genRandTest(int n, int m, int x, int y) {
		Pair[] p = new Pair[n];
		int r = m - rand.nextInt(m + 1);
		for (int i = 0; i < p.length; i++) {
			int a = rand.nextInt(100);
			int b = rand.nextInt(Math.min(a + 1, r + 1));
			r -= b;
			p[i] = new Pair(a, b);
		}
		shuffle(p);
//		System.err.println(solve(new Test(m, x, y, p)));
		return new Test(m, x, y, p);
	}

	Test genRandImpossibleTest(int n, int m, int x, int y) {
		Pair[] p = new Pair[n];
		int r = m - rand.nextInt(m + 1);
		for (int i = 0; i < p.length; i++) {
			int a = rand.nextInt(100);
			int b = rand.nextInt(Math.min(100, m + 1));
			r -= b;
			p[i] = new Pair(a, b);
		}
		shuffle(p);
		return new Test(m, x, y, p);
	}

	Test genMaxTest(int n, int m, int x, int y, int k) {
		Pair[] p = new Pair[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = new Pair(k, k);
		}
		return new Test(m, x, y, p);
	}

	int MAX = 99;

	public void run() {
		write(genMaxTest(MAX, MAX, MAX, MAX, MAX));
		write(genMaxTest(1, MAX, MAX, MAX, MAX));
		write(genRandTest(MAX, 30, MAX, MAX));
		write(genRandTest(MAX, MAX, MAX, MAX));
		write(genRandTest(MAX, MAX, 13, 17));
		write(genRandTest(MAX, MAX, 2, 10));
		write(genRandTest(MAX, 15, 13, 17));
		write(genRandTest(MAX, 20, 23, 10));
//		write(genRandImpossibleTest(MAX, 30, MAX, MAX));
//		write(genRandImpossibleTest(MAX, MAX, 13, 17));
//		write(genRandImpossibleTest(MAX, MAX, 2, 10));
//		write(genRandImpossibleTest(MAX, 15, 13, 17));
//		write(genRandImpossibleTest(MAX, 20, 23, 10));

		write(genRandTest(5, 30, rand.nextInt(MAX + 1), rand.nextInt(MAX + 1)));
		write(genRandTest(6, 40, 0, 10));
		write(genRandTest(6, 40, 0, 10));
		write(genRandTest(6, 40, 0, 0));

		write(genRandTest(10, MAX, MAX, MAX));
		write(genRandTest(15, 25, 13, 17));
		write(genRandTest(13, 10, 2, 10));
		write(genRandTest(9, 15, 13, 17));
		write(genRandTest(5, 20, 23, 10));
		write(genRandImpossibleTest(MAX, 30, rand.nextInt(MAX), rand.nextInt(MAX)));

		for (int i = 0; i < 13; i++) {
			write(genRandTest(rand.nextInt(5) + 1, rand.nextInt(10), rand
					.nextInt(MAX + 1), rand.nextInt(MAX + 1)));
		}
		for (int i = 0; i < 7; i++) {
			write(genRandTest(rand.nextInt(100), rand.nextInt(100), rand
					.nextInt(MAX + 1), rand.nextInt(MAX + 1)));
		}
	}

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