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

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

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int tNumber;

	Random rnd;

	void print(ArrayList<Integer> a) throws IOException {
		int n = a.size();
		if (tNumber < 10) {
			out = new PrintWriter("../tests/0" + tNumber);
		} else {
			out = new PrintWriter("../tests/" + tNumber);
		}
		tNumber++;
		out.println(n);
		for (int i = 0; i < n - 1; i++) {
			out.print((a.get(i) + 1) + " ");
		}
		out.println(a.get(n - 1) + 1);
		out.close();
	}

	void genFull(int n) throws IOException {
		ArrayList<Integer> res = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			res.add(i);
		}
		print(res);
	}

	void genRandom(int n, int k) throws IOException {
		int[] ans = new int[k + 1];
		int[] was = new int[n + 1];
		was[n] = 1;

		for (int i = 0; i < k; i++) {
			ans[i] = rnd.nextInt(n) + 1;
			while (was[ans[i]] == 1) {
				ans[i] = rnd.nextInt(n) + 1;
			}
			was[ans[i]] = 1;
		}
		ans[k] = n;
		ArrayList<Integer>[] arr = new ArrayList[k + 1];
		Arrays.sort(ans);
		int prev = 0;
		for (int i = 0; i <= k; i++) {
			arr[i] = new ArrayList<Integer>();
			for (int j = prev; j < ans[i]; j++) {
				arr[i].add(j);
			}
			Collections.shuffle(arr[i],rnd);
			prev = ans[i];
		}
		ArrayList<Integer> res = new ArrayList<Integer>();
		for (int i = 0; i <= k; i++) {
			for (int j : arr[i]) {
				res.add(j);
			}
		}
		print(res);

	}

	public void solve() throws IOException {
		tNumber = 1;
		rnd = new Random(31);
		ArrayList<Integer> arr;
		Integer[] a = { 1, 0, 3, 2, 5, 4 };
		arr = new ArrayList<Integer>(Arrays.asList(a));
		print(arr);
		Integer[] b = { 0 };
		arr = new ArrayList<Integer>(Arrays.asList(b));
		print(arr);
		genFull(1000);
		for (int i = 0; i < 5; i++) {
			genRandom(rnd.nextInt(500) + 500, 0);
		}
		for (int i = 0; i < 5; i++) {
			genRandom(rnd.nextInt(500) + 500, 1);
		}
		for (int i = 0; i < 5; i++) {
			genRandom(rnd.nextInt(500) + 500, 100 + rnd.nextInt(100));
		}
		genFull(100000);
		for (int i = 0; i < 10; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 0);
		}
		for (int i = 0; i < 10; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 1);
		}
		for (int i = 0; i < 5; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 5 + rnd.nextInt(5));
		}
		for (int i = 0; i < 5; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 10 + rnd.nextInt(10));
		}
		for (int i = 0; i < 5; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 100 + rnd.nextInt(100));
		}
		for (int i = 0; i < 10; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 1000 + rnd.nextInt(1000));
		}
		for (int i = 0; i < 10; i++) {
			genRandom(rnd.nextInt(50000) + 50000, 10000 + rnd.nextInt(10000));
		}

	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}