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

public class TestGen {
    public static void main(String[] args) throws IOException {
        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;
    final int MAXN = 500000;


    void print(ArrayList<Integer>[] test) throws IOException {
        System.err.println(tNumber);
        if (tNumber < 10) {
            out = new PrintWriter("../tests/0" + tNumber);
        } else {
            out = new PrintWriter("../tests/" + tNumber);
        }
        tNumber++;

        out.println(test.length);
        for (int i = 0; i < test.length; i++) {
            out.println(test[i].size());
            out.print(test[i].get(0));
            for (int j = 1; j < test[i].size(); j++) {
                out.print(" " + test[i].get(j));
            }
            out.println();
        }
        out.close();
    }


    void genSimple() throws IOException {
        ArrayList<Integer> al = new ArrayList<Integer>();
        al.add(3);
        al.add(1);
        al.add(2);

        ArrayList<Integer>[] test = new ArrayList[2];
        test[0] = al;

        ArrayList<Integer> a = new ArrayList<Integer>();
        a.add(1);
        a.add(5);
        a.add(3);
        a.add(6);
        test[1] = a;

        print(test);
    }


    int fact(int n) {
        int ans = 1;
        for (int i = 2; i <= n; i++) {
            ans = ans * i;
        }
        return ans;
    }

    void genAllPerm(int n) throws IOException {
        Integer[] p = new Integer[n];
        for (int i = 0; i < n; i++) {
            p[i] = i + 1;
        }
        int k = 0;
        ArrayList<Integer>[] test = new ArrayList[fact(n)];
        do {
            ArrayList<Integer> intList = new ArrayList<Integer>(Arrays.asList(p));
            test[k++] = intList;
        } while (nextPermutation(p));
        print(test);
    }

    void genArrangements(int n, int k) throws IOException  {
        int count = MAXN / n;
        ArrayList<Integer>[] test = new ArrayList[count];
        for (int i = 0; i < count; i++) {
            ArrayList<Integer> al = new ArrayList<Integer>();
            for (int j = 0; j < n; j++) {
                al.add(rnd.nextInt(k) + 1);
            }
            test[i] = al;
        }
        print(test);
    }


    public void generate() throws IOException {
        new File("../tests").mkdir();
        tNumber = 1;
        genSimple();
        rnd = new Random(3131313);
        genAllPerm(7);
        genAllPerm(8);
        genArrangements(7, 5);
        genArrangements(10, 7);
        genArrangements(10, 10);
        genArrangements(100, 1000000000);
        genArrangements(100, 1000000000);
        genArrangements(100, 1000000000);
        genArrangements(100, 1000000000);
        genArrangements(100, 1000000000);
        genArrangements(100, 1000000000);
        genArrangements(MAXN, 10);
        genArrangements(MAXN, 10);
        genArrangements(MAXN, 10);
        genArrangements(MAXN, 10);
        genArrangements(MAXN, 100);
        genArrangements(MAXN, 1000000000);
        genArrangements(MAXN, 1000000000);
        genArrangements(MAXN, 1000000000);
    }

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

    public static boolean nextPermutation(Integer[] p) {
        for (int a = p.length - 2; a >= 0; --a)
            if (p[a] < p[a + 1])
                for (int b = p.length - 1; ; --b)
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
        return false;
    }
}