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

public class Gen {
	FastScanner in;
	PrintWriter out;

	private int done = 0;
	private int donePreliminary = 0;

	class Pair {
		int first, second;

		public Pair(int first, int second) {
			super();
			this.first = first;
			this.second = second;
		}

	}

	final static Random rng = new Random(123456);
	ArrayList<Pair> all = new ArrayList<>();
	int MAX_LEN = (int) 1e5;
	int MAX_M = (int) 1e5;
	int MED_LEN = (int) 1e3;
	int MED_M = (int) 1e3;
	int MAX_X = (int) 1e9;
	String str;
	int x;

	void print() {
		String filename = "" + (done + 1);
		if (done < 9) {
			filename = "0" + filename;
		}
		PrintWriter out = null;
		try {
			out = new PrintWriter(new File("..\\tests\\" + filename));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		out.println(str);
		out.println(all.size() + " " + x);
		for (Pair p : all) {
			out.println(p.first + " " + p.second);
		}
		out.close();
		all.clear();
		done++;
		System.out.println(done);
	}

	void printPrelim() {
		String filename = "" + (donePreliminary + 1);
		if (donePreliminary < 9) {
			filename = "0" + filename;
		}
		PrintWriter out = null;
		try {
			out = new PrintWriter(new File("../preliminary/" + filename));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		out.println(str);
		out.println(all.size() + " " + x);
		for (Pair p : all) {
			out.println(p.first + " " + p.second);
		}
		all.clear();

		out.close();
		donePreliminary++;
		System.out.println(donePreliminary);
	}

	void genRandomString(int len) {
		char[] c = new char[len];
		for (int i = 0; i < c.length; i++) {
			char next = (char) ('0' + rng.nextInt(9) + 1);
			c[i] = next;
		}
		str = new String(c);
	}

	void genRandomString2(int len, int x) {
		char[] c = new char[len];
		for (int i = 0; i < c.length; i++) {
			char next = (char) ('0' + x);
			c[i] = next;
		}
		str = new String(c);
	}

	void genRandomTasks(int number) {
		int len = str.length();
		for (int i = 0; i < number; i++) {
			all.add(new Pair(rng.nextInt(len) + 1, rng.nextInt(9) + 1));
		}
	}

	public void solve() {
		Locale.setDefault(Locale.US);
		File testDir = new File("..\\tests");
		if (!testDir.exists()) {
			testDir.mkdir();
		}
		testDir = new File("..\\preliminary");
		if (!testDir.exists()) {
			testDir.mkdir();
		}

		str = "123123123123";
		x = 123;
		all.add(new Pair(3, 1));
		all.add(new Pair(1, 2));
		all.add(new Pair(3, 9));
		printPrelim();

		// FIRST GROUP - 20 (m = 0) - [1; 15]
		for (int i = 0; i < 5; i++) {
			genRandomString(rng.nextInt(MAX_LEN) + 1);
			x = rng.nextInt(MAX_X - 10) + 10;
			print();
		}
		for (int i = 0; i < 5; i++) {
			genRandomString(MAX_LEN);
			x = rng.nextInt(MAX_X - 10) + 10;
			print();
		}
		for (int i = 0; i < 5; i++) {
			genRandomString(MAX_LEN);
			x = rng.nextInt(100) + 10;
			print();
		}

		// SECOND GROUP - 20 (n, m <= 1000) - [16; 30]
		for (int i = 0; i < 10; i++) {
			genRandomString(MED_LEN);
			x = rng.nextInt(MAX_X - 10) + 10;
			genRandomTasks(MED_M);
			print();
		}
		for (int i = 0; i < 5; i++) {
			genRandomString(MED_LEN);
			x = rng.nextInt(100) + 10;
			genRandomTasks(MED_M);
			print();
		}

		// THIRD GROUP - 60 - [31; 45]
		for (int i = 0; i < 5; i++) {
			genRandomString(MAX_LEN);
			x = rng.nextInt(MAX_X - 10) + 10;
			genRandomTasks(MAX_M);
			print();
		}
		for (int i = 0; i < 10; i++) {
			int y = rng.nextInt(8) + 1;
			int tmp = rng.nextInt(6) + 2;
			genRandomString2((MAX_LEN / 2 + rng.nextInt(MAX_LEN / 2))/tmp*tmp, y);
			x = 0;
			for (int j = 0; j < tmp; j++)
				x = x * 10 + y;
			for (int j =0; j < MAX_M / 4;j++) {
				int pos1 = 1 + rng.nextInt(str.length());
				int pos2 = 1 + rng.nextInt(str.length());
			    all.add(new Pair(pos1, y + 1));
				all.add(new Pair(pos2, y + 1));
				all.add(new Pair(pos1, y));
			    all.add(new Pair(pos2, y));
			}
			print();
		}

	}

	public void run() {
		solve();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

	}

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