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

public class TestGen {
    static int nTests = 0;
    static final Random r = new Random(444444444444442L);

    static class Point {
        public final int x, y;
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return x * 31 + y * 366239;
        }

        public boolean equals(Object o) {
            Point p = (Point) o;
            return x == p.x && y == p.y;
        }
    }

    static class Fleet {
        public final Point[] ships;
        public final Point direction;
        public final int t;
        public Fleet(int t, Point direction, Point[] ships) {
            this.ships = ships;
            this.direction = direction;
            this.t = t;
        }
    }

    public static void write(Fleet... fleets) {
        try {
            if (fleets.length != 2) {
                throw new AssertionError();
            }
            PrintWriter out = new PrintWriter(String.format("%02d", nTests + 1));
            for (Fleet f : fleets) {
                out.println(f.ships.length + " " + f.t + " " + f.direction.x + " " + f.direction.y);
                for (Point p : f.ships) {
                    out.println(p.x + " " + p.y);
                }
            }
            if (out.checkError()) {
                System.err.println("An error has occured while generating test #" + (nTests + 1));
                --nTests;
            }
            out.close();
            ++nTests;
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public static Fleet f(int t, int dx, int dy, int... ships) {
        if (ships.length % 2 != 0) {
            throw new AssertionError("number of ship coordinates must be divisible by 2");
        }
        Point dir = new Point(dx, dy);
        Point[] sh = new Point[ships.length / 2];
        for (int i = 0; i < sh.length; ++i) {
            sh[i] = new Point(ships[2 * i], ships[2 * i + 1]);
        }
        return new Fleet(t, dir, sh);
    }

    private static void writeSmallRandom() {
        Fleet[] fleets = new Fleet[2];
        Set<Point> all = new HashSet<Point>();
        for (int g = 0; g < fleets.length; ++g) {
            int t = 1 + r.nextInt(10);
            Point direction = new Point(r.nextInt(21) - 10, r.nextInt(21) - 10);
            Point[] pts = new Point[1 + r.nextInt(100)];
            for (int i = 0; i < pts.length; ++i) {
                do {
                    pts[i] = new Point(r.nextInt(1001) - 500, r.nextInt(1001) - 500);
                } while (all.contains(pts[i]));
                all.add(pts[i]);
            }
            fleets[g] = new Fleet(t, direction, pts);
        }
        write(fleets);
    }

    private static void writeLargeRandom(int maxFleetSize) {
        Fleet[] fleets = new Fleet[2];
        Set<Point> all = new HashSet<Point>();
        int sum = 0;
        for (int g = 0; g < fleets.length; ++g) {
            int t = 1 + r.nextInt(10);
            Point direction = new Point(r.nextInt(21) - 10, r.nextInt(21) - 10);
            Point[] pts = new Point[1 + r.nextInt(10000)];
            sum += pts.length;
            for (int i = 0; i < pts.length; ++i) {
                do {
                    pts[i] = new Point(r.nextInt(1000001) - 500000, r.nextInt(1000001) - 500000);
                } while (all.contains(pts[i]));
                all.add(pts[i]);
            }
            fleets[g] = new Fleet(t, direction, pts);
        }
        write(fleets);
    }

    private static void writeLargeRandom2() {
        Fleet[] fleets = new Fleet[2];
        Set<Point> all = new HashSet<Point>();
        int sum = 0;
        for (int g = 0; g < fleets.length; ++g) {
            int t = g == 0 ? 10 : 9;
            Point direction = new Point(r.nextInt(21) - 10, r.nextInt(21) - 10);
            Point[] pts = new Point[10000];
            sum += pts.length;
            for (int i = 0; i < pts.length; ++i) {
                do {
                    pts[i] = new Point(r.nextInt(10000001) - 5000000, r.nextInt(10000001) - 5000000);
                } while (all.contains(pts[i]));
                all.add(pts[i]);
            }
            fleets[g] = new Fleet(t, direction, pts);
        }
        write(fleets);
    }

    private static void writeOneCategory() {
        Fleet[] fleets = new Fleet[2];
        Set<Point> all = new HashSet<Point>();
        int sum = 0;
        for (int g = 0; g < fleets.length; ++g) {
            int t = 1 + r.nextInt(10);
            Point direction = new Point(1, 1);
            Point[] pts = new Point[100 + r.nextInt(Math.min(10000, 50000 - sum) - 100)];
            sum += pts.length;
            for (int i = 0; i < pts.length; ++i) {
                do {
                    int q = r.nextInt(2000000001) - 1000000000;
                    pts[i] = new Point(q, q);
                } while (all.contains(pts[i]));
                all.add(pts[i]);
            }
            fleets[g] = new Fleet(t, direction, pts);
        }
        write(fleets);
    }

    private static void writeOneCategory2() {
        Fleet[] fleets = new Fleet[2];
        Set<Point> all = new HashSet<Point>();
        int sum = 0;
        for (int g = 0; g < fleets.length; ++g) {
            int t = g == 0 ? 10 : 9;
            Point direction = new Point(1, 1);
            Point[] pts = new Point[10000];
            sum += pts.length;
            for (int i = 0; i < pts.length; ++i) {
                do {
                    int q = r.nextInt(2000000001) - 1000000000;
                    pts[i] = new Point(q, q);
                } while (all.contains(pts[i]));
                all.add(pts[i]);
            }
            fleets[g] = new Fleet(t, direction, pts);
        }
        write(fleets);
    }

    public static void main(String[] args) {
        /** 01 **/
        write(f(1, 1, 0, 2, 0, 1, 1, 1, -1), f(2, -2, 0, 8, 1, 8, 2));
        /** 02 - simple "-1" **/
        write(f(1, 2, 0, 1, 1), f(1, -2, 0, 2, 2));
        /** 03 - jumping over test **/
        write(f(1, 2, 0, 0, 0, 2, 0), f(1, -1, 0, 9, 0, 7, 0));
        /** 04 - probable negative answer test **/
        write(f(1, -2, 0, 0, 0, 2, 0), f(1, 1, 0, 9, 0, 7, 0));
        /** 05 - bad test for simulators **/
        write(f(1, 1, 1, -1000000000, -1000000000), f(1, -1, -1, 1000000000, 1000000000));
        /** 06 - bad tests for those who think answer is int32 **/
        write(f(9, 1, 1, -1000000000, -1000000000), f(10, 1, 1, 1000000000, 1000000000));
        /** 07 - bad tests for those who think result coordinates are int32 (jury solution doesn't care) **/
        write(f(1, 10, 10, -1000000000, -1000000000), f(1, 9, 9, 1000000000, 1000000000));
        /** 08 - fleets' average relative speed is (0; 0). Who else thinks this means -1? **/
        write(f(2, 2, 0, 0, 0), f(3, 3, 0, 1, 0));
        /** 09 */
        write(
            f(3, -2, 3, 5, 1, 7, 0, 6, 3),
            f(1, 2, 3, 1, -3)
        );
        /** 10 */
        write(f(10, 1, 1, -1000000000, -1000000000), f(9, -1, -1, 1000000000, 1000000000));

        for (int i = 0; i < 5; ++i) {
            writeSmallRandom();
        }
        for (int i = 0; i < 5; ++i) {
            writeLargeRandom(1000);
        }
        for (int i = 0; i < 10; ++i) {
            writeLargeRandom(10000);
        }
        for (int i = 0; i < 5; ++i) {
            writeOneCategory();
        }
        for (int i = 0; i < 5; ++i) {
            writeLargeRandom2();
        }
        for (int i = 0; i < 5; ++i) {
            writeOneCategory2();
        }
    }
}
