import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class TestsGen {

    Random rnd = new Random(0);

    final static int MAXN = 900000;

    String nextRandomString(int n, Random rnd, int maxLetter) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append((char) (rnd.nextInt(maxLetter) + 'a'));
        }
        return sb.toString();
    }

    void run() throws FileNotFoundException {
        // out(new Test(
        // new String[]{"stepan1", "vasiliy4", "stepan4", "stepan3",
        // "vladimir1000000"},
        // new String[]{"stepan", "stepan", "vasiliy"}
        // ));

        // 01--05 --- no initial squirells
        Test t = new Test();
        t.newNames.add("a");
        out(t);

        t = new Test();
        t.newNames
                .add("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        t.newNames.add("aa");
        out(t);

        t = new Test();
        t.newNames.add("a");
        t.newNames.add("b");
        t.newNames.add("a");
        out(t);

        t = new Test();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < MAXN; i++) {
            sb.append((char) (rnd.nextInt(26) + 'a'));
        }
        t.newNames.add(sb.toString());
        out(t);

        t = new Test();
        sb = new StringBuilder();
        for (int i = 0; i < Math.sqrt(2 * MAXN); i++) {
            sb.append((char) (rnd.nextInt(26) + 'a'));
            t.newNames.add(sb.toString());
        }
        t.shuffle();
        out(t);

        t = new Test();
        for (int i = 0; i < MAXN / 20; i++) {
            t.newNames.add(nextRandomString(20, rnd, 26));
        }
        t.shuffle();
        out(t);

        t = new Test();
        for (int i = 0; i < MAXN / 20; i++) {
            t.newNames.add(nextRandomString(20, rnd, 2));
        }
        t.shuffle();
        out(t);

        t = new Test();
        for (int i = 0; i < MAXN / 21; i++) {
            t.newNames.add(nextRandomString(rnd.nextInt(40) + 1, rnd, 2));
        }
        t.shuffle();
        out(t);

        // 09--20
        t = new Test();
        t.names.add("a2");
        t.newNames.add("a");
        out(t);

        t = new Test();
        t.names.add("a1");
        t.newNames.add("a");
        out(t);

        t = new Test();
        t.names.add(String.format("a%d", MAXN / 4));
        for (int i = 0; i < MAXN / 3; i++) {
            t.newNames.add("a");
        }
        out(t);

        t = new Test();
        for (int i = 0; i < MAXN / 50; i++) {
            t.names.add(nextRandomString(rnd.nextInt(40) + 1, rnd, 2)
                    + (rnd.nextInt(100) + 1));
            t.newNames.add(nextRandomString(rnd.nextInt(40) + 1, rnd, 2));
        }
        out(t);

        for (int q = 0; q < 5; q++) {
            t = new Test();
            for (int i = 0; i < MAXN / (1 << (2 * q + 6)); i++) {
                t.names.add(nextRandomString(rnd.nextInt(40) + 1, rnd, 26)
                        + (rnd.nextInt(100) + 1));
                t.newNames.add(nextRandomString(rnd.nextInt(40) + 1, rnd, 26));
            }
            out(t);
        }
        
        t = new Test();
        sb = new StringBuilder();
        for (int i = 0; i < Math.sqrt(MAXN); i++) {
            sb.append((char) (rnd.nextInt(26) + 'a'));
            t.newNames.add(sb.toString());
            t.names.add(sb.toString() + 1);
        }
        t.shuffle();
        out(t);
        
        t = new Test();
        for (int i = 0; i < MAXN / 10; i++) {
            t.names.add("a" + (i + 1));
            t.newNames.add("a");
        }
        t.shuffle();
        out(t);
        
        t = new Test();
        for (int i = 0; i < MAXN / 12; i++) {
            t.names.add(nextRandomString(rnd.nextInt(4) + 1, rnd, 2)
                    + (rnd.nextInt(10000) + 1));
            t.newNames.add(nextRandomString(rnd.nextInt(4) + 1, rnd, 2));
        }
        out(t);
    }

    public static void main(String[] args) throws FileNotFoundException {
        new TestsGen().run();
    }

    class Test {
        Collection<String> names;
        Collection<String> newNames;

        public Test() {
            names = new ArrayList<String>();
            newNames = new ArrayList<String>();
        }

        public Test(String[] n, String[] nn) {
            names = new ArrayList<String>(Arrays.asList(n));
            newNames = new ArrayList<String>(Arrays.asList(nn));
        }

        void shuffle() {
            Collections.shuffle((List<?>) names, rnd);
            Collections.shuffle((List<?>) newNames, rnd);
        }

    }

    static int currentTest = 0;

    void out(Test t) throws FileNotFoundException {
        currentTest++;
        rnd = new Random(currentTest * currentTest + 3);
        PrintWriter out = new PrintWriter(String.format("%02d", currentTest));
        out.println(t.names.size());
        for (String s : t.names) {
            out.println(s);
        }
        out.println(t.newNames.size());
        for (String s : t.newNames) {
            out.println(s);
        }
        out.close();
    }
}
