import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class TestsGen {
	static int testcount = 0;
	
	static int maxn = 1000;

	static Random random = new Random(985384573);

	static void write(int n, BigInteger k) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		out.println(n + " " + k);
		out.close();
	}
	
	static BigInteger nextRandomBigInteger(BigInteger n) {
	    BigInteger res = new BigInteger(n.bitLength(), random);
	    while(res.compareTo(n) >= 0) {
	        res = new BigInteger(n.bitLength(), random);
	    }
	    return res;
	}	
	
	static void writeRand(int n) throws IOException {
		BigInteger max = BigInteger.valueOf(3).pow(n).add(BigInteger.ONE);
		write(n, nextRandomBigInteger(max));
	}

	static void writeMin(int n) throws IOException {
		write(n, BigInteger.ZERO);
	}
	
	static void writeMax(int n) throws IOException {
		BigInteger max = BigInteger.valueOf(3).pow(n);
		write(n, max);
	}

	public static void main(String[] args) throws IOException {
		while (new File(String.format("%02d.t", testcount + 1)).exists()) {
			testcount++;
		}
		for (int i = 0; i <= 3; i++) {
			write(1, BigInteger.valueOf(i));
		}
		for (int i = 2; i <= 10; i++) {
			writeRand(i);
		}
		writeRand(20);
		writeRand(100);
		for (int i = 0; i < 10; i++) {
			writeRand(random.nextInt(maxn) + 1);
		}
		for (int i = 0; i < 3; i++) {
			writeMin(random.nextInt(maxn) + 1);
			writeMax(random.nextInt(maxn) + 1);
		}
		writeRand(maxn);
		writeRand(maxn);
		writeMin(maxn);
		writeMax(maxn);
	}

}
