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

public class TestsGen {
	static int testcount = 0;

	static Random random = new Random(36498732);
	
	static int MAXN = 100000;
	static int MAX = (int) 1e9;

	static void write(int[] a, int k) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		out.println(a.length + " " + k);
		for (int i = 0; i < a.length; i++) {
			if (i > 0) out.print(" ");
			out.print(a[i]);
		}
		out.println();
		out.close();
	}
	
	static void writeRand(int n, int k, int max) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = random.nextInt(max) + 1;
		}
		write(a, k);
	}
	
	static void writeSort(int n, int k, int max) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = random.nextInt(max) + 1;
		}
		Arrays.sort(a);
		write(a, k);
	}
	
	static void writePeek(int n, int k, int max) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = random.nextInt(max) + 1;
		}
		Arrays.sort(a);
		int[] b = new int[n];
		int i = 0;
		int j = n - 1;
		int t = 0;
		while (i <= j) {
			b[i++] = a[t++];
			if (i <= j) {
				b[j--] = a[t++];
			}
		}
		write(b, k);
	}
	
	static void writeRandPeek(int n, int k, int max, int max2) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = random.nextInt(max) + 1;
		}
		a[random.nextInt(n)] = max2;
		write(a, k);
	}
	
	
	public static void main(String[] args) throws IOException {
		while (new File(String.format("%02d.t", testcount + 1)).exists()) {
			testcount++;
		}
		writeRand(10, 1, 100);
		writeRand(15, 7, 100);
		writeRandPeek(12, 3, 100, MAX);
		writeRandPeek(21, 17, 10, 100);
		writeRandPeek(35, 2, 10, 566);
		writeRandPeek(77, 5, 100, 25566);
		writeRand(20, 4, 100);
		writeRand(100, 87, 1000);
		writeRand(1000, 634, 3);
		writeRand(MAXN, 1, MAX);
		writeRand(MAXN, 2, MAX);
		writeRand(MAXN, 5, 10);
		writeRand(MAXN, 10, MAX);
		writeRand(MAXN, 100, MAX);
		writeRand(MAXN, 1000, MAX);
		writeRand(MAXN, 10000, MAX);
		writeRand(MAXN, MAXN / 2, MAX);
		writeRand(MAXN, MAXN / 2, 10);
		writeRand(MAXN, MAXN - 1, MAX);
		writeRand(MAXN, MAXN, MAX);
		writeRand(MAXN, 666, 1);
		writeRand(MAXN, 25566, 2);
		writeRandPeek(MAXN, 239, 100, MAX);
		writeSort(MAXN, 56630, MAX);
		writePeek(MAXN, 23930, MAX);
	}

}
