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

// Version 1.6 TestGen

public class TestGen {

    static int done = 0;

    static final Random rand = new Random(556668949239L);

    static final int MAX_N = 1000;
    static final int MAX_VALUE = 100;

    static ArrayList<Integer> data = new ArrayList<Integer>();

    static void print(int k, boolean f) throws IOException {
	if (data.size() < 3) {
	    data.clear();
	    return;
	}
	done++;
	System.err.println(done + " " + data.size());
	PrintWriter out;
	if (done < 10)
	    out = new PrintWriter("../tests/0" + String.valueOf(done));
	else
	    out = new PrintWriter("../tests/" + String.valueOf(done));
	if (f)
	    Collections.shuffle(data, rand);
	int n = data.size();
	if (k < 1)
	    k = randFromTo(1, Math.min(10, n - 1));
	out.println(n + " " + k);
	for (int i = 0; i < n; i++)
	    out.print(data.get(i) + " ");
	out.println();
	data.clear();
	out.close();
    }

    static int randHalf(int maxValue) {
	return randFromTo((maxValue + 1) / 2, maxValue);
    }

    static int randFromTo(int from, int to) {
	return rand.nextInt(to - from + 1) + from;
    }

    static void genSimple() throws IOException {
	data.add(1);
	data.add(2);
	data.add(4);
	print(2, false);
    }

    static void genRand(int cnt, int minValue, int maxValue) throws IOException {
	for (int i = 0; i < cnt; i++) {
	    data.add(randFromTo(minValue, maxValue));
	}
    }

    static void genEqual(int cnt, int value) throws IOException {
	for (int i = 0; i < cnt; i++) {
	    data.add(value);
	}
    }

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

	genEqual(MAX_N / 10, MAX_VALUE);
	print(1, true);

	genEqual(randHalf(MAX_N), MAX_VALUE);
	print(-1, true);

	genRand(13, 23, 42);
	print(1, true);

	genEqual(randHalf(MAX_N), 1);
	print(2, true);

	genEqual(randHalf(MAX_N), 1);
	print(1, true);

	genEqual(randHalf(MAX_N), 2);
	print(randFromTo(3, 8), true);

	genEqual(randHalf(MAX_N), 10);
	print(2, true);

	genEqual(3, 4);
	print(2, true);

	for (int max : new int[] { 20, MAX_N }) {
	    for (int i = 2; i < 10; i++) {
		for (int j = 0; j < i; j++)
		    genEqual(randHalf(MAX_N / i), randFromTo(1, max));
		print(-1, true);
	    }
	}

	for (int i = 1; i < 11; i++) {
	    genRand(randHalf(Math.max(2 * i + 2, 10)), 1, 10);
	    print(i, true);
	}

	for (int k = 1; k < 11; k++) {
	    genRand(randHalf(MAX_N), 1, MAX_VALUE);
	    print(k, true);
	    genRand(MAX_N, MAX_VALUE - 5, MAX_VALUE);
	    print(k, true);
	    genRand(k + 1, 1, k + 2);
	    print(k, true);
	}

	return;
    }
}
