/**
 * Created by GShark on 20.11.2014.
 */
import java.io.*;
import java.util.*;

public class TestsGen {
    public static void main(String[] args) throws IOException {
        new TestsGen().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;
    final int MAXN = 100_000;
    final int MAXX = 100_000_000;
    ArrayList<Integer> a, b;

    int rand(int n) {
        return rnd.nextInt(n);
    }

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

    // here starts gens

    void genSample1() throws IOException {
        a.add(10);
        a.add(5);
        a.add(10);
        b.add(5);
        print(a, b);
    }

    void genSample2() throws IOException {
        int[] ara = {2, 5, 4, 1, 7, 5};
        int[] arb = {2, 3, 1, 3, 2, 4, 6};
        for (int i = 0; i < ara.length; i++) {
            a.add(ara[i]);
        }
        for (int i = 0; i < arb.length; i++) {
            b.add(arb[i]);
        }
        print(a, b);
    }

    void genRand(int n, int m, int max) throws IOException {
        for (int i = 0; i < n; i++) {
            a.add(rand(max) + 1);
        }
        for (int i = 0; i < m; i++) {
            b.add(rand(max) + 1);
        }
        print(a, b);
    }

    void genSpecial1(int n, int m, int x) throws IOException {
        for (int i = 0; i < n; i++) {
            a.add(x + i);
        }
        for (int i = 0; i < m; i++) {
            b.add(x + i);
        }
        print(a, b);
    }

    void genSpecial2(int n, int m, int x) throws IOException {
        for (int i = 0; i < n; i++) {
            a.add(x + i);
        }
        for (int i = m - 1; i >= 0; i--) {
            b.add(x + i);
        }
        print(a, b);
    }

    void genSpecial3(int n, int m) throws IOException {
        for (int i = 0; i < n; i++) {
            if (rand(2) == 1) {
                a.add(MAXX);
            } else {
                a.add(1);
            }
        }
        for (int i = 0; i < m; i++) {
            if (rand(2) == 1) {
                b.add(MAXX);
            } else {
                b.add(1);
            }
        }
        print(a, b);
    }

    void genSpecial4(int n, int m) throws IOException {
        for (int i = 0; i < n; i++) {
            if (rand(2) == 1) {
                a.add(MAXX);
            } else {
                a.add(rand(MAXX) + 1);
            }
        }
        for (int i = 0; i < m; i++) {
            if (rand(2) == 1) {
                b.add(MAXX);
            } else {
                b.add(rand(MAXX) + 1);
            }
        }
        print(a, b);
    }



    void genMax(int n, int m) throws IOException {
        for (int i = 0; i < n; i++) {
            a.add(MAXX);
        }
        for (int i = 0; i < m; i++) {
            b.add(MAXX);
        }
        print(a, b);
    }


    //the end of the gens

    public void generate() throws IOException {
        new File("../tests").mkdir();
        tNumber = 1;
        rnd = new Random(388282447);
        a = new ArrayList<Integer>();
        b = new ArrayList<Integer>();

        genSample1();
        genSample2();
        genRand(10, 12, 20);
        genSpecial1(20, 5, 10);
        genSpecial2(7, 12, 13);
        genSpecial3(20, 9);
        genSpecial4(20, 20);
        genMax(30, 10);

        genRand(1, 10, 100);
        genRand(50, 3, 100);

        int x = MAXN / 2;
        for (int i = 0; i < 5; i++) {
            genRand(rand(x) + x, rand(x) + x, (i + 1) * 10);
            genRand(rand(MAXN) + 1, rand(MAXN) + 1, MAXX);
            genRand(rand(x) + x, rand(x) + x, MAXX);
        }

        for (int i = 0; i < 3; i++) {
            genSpecial1(rand(x) + x, rand(x) + x, rand(MAXX - MAXN) + 1);
            genSpecial2(rand(x) + x, rand(x) + x, rand(MAXX - MAXN) + 1);
            genSpecial3(rand(x) + x, rand(x) + x);
            genSpecial4(rand(x) + x, rand(x) + x);
        }

        genRand(MAXN, MAXN, MAXX);
        genSpecial1(MAXN, MAXN, MAXX - MAXN);
        genSpecial2(MAXN, MAXN, MAXX - MAXN);
        genSpecial3(MAXN, MAXN);
        genSpecial4(MAXN, MAXN);
        genMax(MAXN, MAXN);


    }

    public void run() throws IOException {
        Locale.setDefault(Locale.US);
        generate();
    }
}
