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

public class gen_parade {

    static String TESTS_PATH = "../tests";
    final int MAX_H = (int) 1e9;
    final int MAX_N = 100000;
    final int SMALL_N = 100;
    final int SMALL_H = 200;
    int[] SMALL_ANTI_GREED = {1, 5, 3, 4, 2, 4, 5};
    int[] SMALL_ANTI_GREED2 = {3, 4, 8, 10, 7, 9, 4};


    int[][] HAND = {
            {6, 1, 4, 3, 2, 5},
            {1, 3, 2, 4, 6, 5},
            {1, 1, 1},
            {1, 1},
            {1, 2},
            {2, 1},
            {2, 1, 2},
            {1, 2, 1},
            {7, 6, 5, 3, 3, 2, 6},
            SMALL_ANTI_GREED,
            SMALL_ANTI_GREED2
    };

    public void solve() throws IOException {
        for (int[] a : HAND) {
            writeTest(a);
        }
        for (int i = 0; i < 5; i++) {
            writeTest(randomTestPossible(10, 10));
        }

        writeTest(inc(SMALL_N));
        writeTest(dec(SMALL_N));
        writeTest(antiGreedTestV1(SMALL_N));
        writeTest(antiGreedTestV2(SMALL_N));
        for (int i = 0; i < 5; i++) {
            writeTest(randomTestPossible(SMALL_N, SMALL_H));
        }
        writeTest(randomTest(SMALL_N, SMALL_H));

        writeTest(inc(MAX_N));
        writeTest(dec(MAX_N));
        writeTest(concat(inc(MAX_N / 2), dec(MAX_N / 2)));
        writeTest(concat(dec(MAX_N / 2), inc(MAX_N / 2)));
        writeTest(mergeIncAndDec(MAX_N));
        writeTest(antiGreedTestV1(MAX_N));
        for (int i = 0; i < 5; i++) {
            writeTest(randomTestPossible(MAX_N, MAX_H));
        }
        writeTest(antiGreedTestV2(MAX_N));
        writeTest(randomTest(MAX_N, MAX_H));
        writeTest(specialTest1(MAX_N));
        writeTest(specialTest2(MAX_N));
    }


    ArrayList<Integer> antiGreedTestV1(int len) {
        len -= SMALL_ANTI_GREED.length;
        len /= 2;
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = len - 1; i >= 0; i--) {
            res.add(i + 6);
        }
        for (int i : SMALL_ANTI_GREED) {
            res.add(i);
        }
        for (int i = 0; i < len; i++) {
            res.add(i + 6);
        }
        return res;
    }
    ArrayList<Integer> specialTest1(int len) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = 0; i < len / 3; i++) {
            res.add(2 * i + 1);
            res.add(2 * i + 2);
            res.add(len - i);
        }
        return res;
    }
    ArrayList<Integer> specialTest2(int len) {
        ArrayList<Integer> res = specialTest1(len);
        Collections.reverse(res);
        return res;
    }

    ArrayList<Integer> antiGreedTestV2(int len) {
        len -= SMALL_ANTI_GREED2.length;
        len /= 2;
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = len - 1; i >= 0; i--) {
            res.add(i + 6);
        }
        for (int i : SMALL_ANTI_GREED2) {
            res.add(i);
        }
        for (int i = 0; i < len; i++) {
            res.add(i + 6);
        }
        return res;
    }

    ArrayList<Integer> inc(int n) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = 1; i <= n; i++) {
            res.add(i);
        }
        return res;
    }

    ArrayList<Integer> dec(int n) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = n; i >= 1; i--) {
            res.add(i);
        }
        return res;
    }

    ArrayList<Integer> concat(ArrayList<Integer> a, ArrayList<Integer> b) {
        a.addAll(b);
        return a;
    }


    ArrayList<Integer> randomTestPossible(int len, int max) {
        int k = rand.nextInt(len - 2) + 1;
        ArrayList<Integer> inc = randomIncrease(k, max);
        ArrayList<Integer> dec = randomDecrease(len - k, max);
        return randomMerge(inc, dec);
    }

    ArrayList<Integer> randomTest(int len, int max) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        for (int i = 0; i < len; i++) {
            res.add(rand.nextInt(max) + 1);
        }
        return res;
    }

    ArrayList<Integer> mergeIncAndDec(int totalLength) {
        int k = rand.nextInt(totalLength - 2) + 1;
        return randomMerge(inc(k), dec(totalLength - k));
    }

    ArrayList<Integer> randomIncrease(int len, int max) {
        if (max < len) {
            return null;
        }
        TreeSet<Integer> val = new TreeSet<Integer>();
        while (val.size() < len) {
            val.add(rand.nextInt(max) + 1);
        }
        return new ArrayList<Integer>(val);
    }

    ArrayList<Integer> randomDecrease(int len, int max) {
        ArrayList<Integer> inc = randomIncrease(len, max);
        Collections.reverse(inc);
        return inc;
    }

    ArrayList<Integer> randomMerge(ArrayList<Integer> a, ArrayList<Integer> b) {
        ArrayList<Boolean> what = new ArrayList<Boolean>();
        for (int i = 0; i < a.size(); i++) {
            what.add(true);
        }
        for (int i = 0; i < b.size(); i++) {
            what.add(false);
        }
        Collections.shuffle(what, rand);
        ArrayList<Integer> res = new ArrayList<Integer>();
        int ia = 0;
        int ib = 0;
        for (boolean bool : what) {
            if (bool) {
                res.add(a.get(ia++));
            } else {
                res.add(b.get(ib++));
            }
        }
        return res;
    }


    public static void main(String[] args) {
        if (args.length > 0 && args[0].equals("stress")) {
            new gen_parade().stress();
            return;
        }
        File f = new File(TESTS_PATH);
        if (!f.exists()) {
            f.mkdir();
        }
        new gen_parade().run();
    }

    private void stress() {
        rand = new Random(System.nanoTime());
        openStress();
        writeTestImpl(randomTest(7, 10));
        close();
    }


    void writeTest(List<Integer> a) {
        open();
        writeTestImpl(a);
        close();
    }

    private void writeTestImpl(List<Integer> a) {
        out.println(a.size());
        for (int i = 0; i < a.size(); i++) {
            out.print(a.get(i));
            if (i < a.size() - 1) {
                out.print(" ");
            }
        }
        out.println();
    }

    void writeTest(int[] a) {
        open();
        out.println(a.length);
        for (int i = 0; i < a.length; i++) {
            out.print(a[i]);
            if (i < a.length - 1) {
                out.print(" ");
            }
        }
        out.println();
        close();
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    static Random rand = new Random(6439586L);
    PrintWriter out;
    int I = 0;

    String getName(int i) {
        return TESTS_PATH + "/" + ((i < 10) ? "0" : "") + i;
    }

    void open() {
        try {
            ++I;
            System.out.println("Generating test " + I);
            out = new PrintWriter(getName(I));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void openStress() {
        try {
            out = new PrintWriter("parade.in");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void close() {
        out.close();
    }

    static final String ALPHA = "abcdefghijklmnopqrstuvwxyz";

    static String randString(int len, String alpha) {
        StringBuilder ans = new StringBuilder();
        int k = alpha.length();
        for (int i = 0; i < len; i++) {
            ans.append(alpha.charAt(rand.nextInt(k)));
        }
        return ans.toString();
    }

    static long rand(long l, long r) {
        return l + (rand.nextLong() >>> 1) % (r - l + 1);
    }

    static int rand(int l, int r) {
        return l + rand.nextInt(r - l + 1);
    }
}
