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

public class TestsGen {

    int testCount;

    void write(String s) throws IOException {
        PrintWriter pw = new PrintWriter(String.format("../tests/%02d", ++testCount));
        System.out.println(testCount);
        pw.println(s);
        pw.close();
    }
    
    Random random = new Random(43534543);

    void write(int n, int[] x, int[] y) throws IOException {
        StringBuilder res = new StringBuilder();
        res.append(Integer.toString(n) + "\r\n");
        for (int i = 0; i <= n; i++) {
            res.append(Integer.toString(x[i]) + " " + Integer.toString(y[i]));
            if (i < n) res.append("\r\n");
        }
        write(res.toString());
    }

    int getRandomInt(int l, int r) {
        return l + random.nextInt(r - l + 1);
    }

    void genRand(int n) throws IOException {
        int ax[] = new int[n + 1], ay[] = new int[n + 1];
        for (int i = 0; i < n + 1; i++) {
            int x = getRandomInt((int)-1e9, (int)1e9);
            int y = getRandomInt((int)-1e9, (int)1e9);
            ax[i] = x;
            ay[i] = y;
        }
        write(n, ax, ay);
    }

    void genOneLine(int n, int m) throws IOException {
        int ax[] = new int[n + 1];
        int ay[] = new int[n + 1];
        int x0 = getRandomInt((int)-5e8, (int)5e8);
        int y0 = getRandomInt((int)-5e8, (int)5e8);
        ax[0] = x0;
        ay[0] = y0;
        for (int i = 0; i < n / m; i++) {
            int x = getRandomInt((int)-3e5, (int)3e5);
            int y = getRandomInt((int)-3e5, (int)3e5);
            boolean used[] = new boolean[3000];
            boolean f = random.nextInt(6) == 0;
            for (int j = 0; j < m; j++) {
                int k = 0;
                while (true) {
                    k = getRandomInt(-1500, 1499);
                    if (used[k + 1500] == false && k != 0 && (!f || k > 0)) {
                        used[k + 1500] = true;
                        break;
                    }
                }
                ax[i * m + j + 1] = x0 + x * k;
                ay[i * m + j + 1] = y0 + y * k;
            }
        }
        write(n, ax, ay);
    }

    void genEps(int x0, int y0, int n, int[] x, int[] y) throws IOException {
        String res = "";
        ArrayList<Integer> vx = new ArrayList<Integer>();
        ArrayList<Integer> vy = new ArrayList<Integer>();
        vx.add(x0);
        vy.add(y0);
        for (int i = 0; i < n; i++) {
            for (int dx = -2; dx <= 2; dx++) {
                for (int dy = -2; dy <= 2; dy++) {
                    if (x[i] + dx != x0 || y[i] + dy != y0) {
                        vx.add(x[i] + dx);
                        vy.add(y[i] + dy);
                    }
                }
            }
        }
        int an = vx.size();
        int ax[] = new int[an];
        int ay[] = new int[an];
        for (int i = 0; i < an; i++) {
            ax[i] = vx.get(i);
            ay[i] = vy.get(i);
        }
        write(an - 1, ax, ay);
    }

    void run() throws IOException {
        new File("../tests").mkdir();
        
        write("6\r\n0 0\r\n1 1\r\n-1 1\r\n1 -1\r\n-1 -1\r\n2 0\r\n0 2");
        write("3\r\n0 0\r\n0 1\r\n-1 -1\r\n1 -1");
        write("3\r\n0 0\r\n1 0\r\n-1 1\r\n-1 -1");
        write("4\r\n0 0\r\n101 100\r\n101 -100\r\n-99 100\r\n-99 -100");
        write("9\r\n0 0\r\n10 0\r\n10 1\r\n10 -1\r\n-10 -10\r\n-9 -9\r\n-11 -11\r\n-10 10\r\n-9 9\r\n-11 11");
        write("11\r\n-3 4\r\n0 5\r\n5 0\r\n0 -5\r\n-5 0\r\n3 4\r\n4 3\r\n-3 -4\r\n-4 -3\r\n-4 3\r\n4 -3\r\n3 -4");
        write("12\r\n5 5\r\n5 0\r\n0 5\r\n1 2\r\n2 1\r\n8 1\r\n1 8\r\n2 9\r\n9 2\r\n5 10\r\n10 5\r\n8 9\r\n9 8");
        write("16\r\n0 0\r\n-2 2\r\n-1 2\r\n0 2\r\n1 2\r\n2 2\r\n2 1\r\n2 0\r\n2 -1\r\n2 -2\r\n1 -2\r\n0 -2\r\n-1 -2\r\n-2 -2\r\n-2 -1\r\n-2 0\r\n-2 1");

        for (int i = 0; i < 2; i++) genRand(100);
        for (int i = 0; i < 6; i++) genRand(200);
        for (int i = 0; i < 2; i++) genRand(100000);        
        
        genOneLine(12, 4);
        genOneLine(30, 6);
        genOneLine(60, 10);
        genOneLine(300, 15);
        genOneLine(100000, 1000);
        genOneLine(100000, 100);
        genOneLine(100000, 10);
        genOneLine(100000, 5);

        {
            int[] x, y;
            x = new int[9];
            y = new int[9];
            x[0] = y[0] = 0;
            for (int i = 1; i < 9; i++) {
                if (i <= 4) {
                    x[i] = 999999990;
                    y[i] = 10;
                } else {
                    x[i] = 10;
                    y[i] = 999999990;               
                }
                if (i % 2 == 0) {
                    x[i] = -x[i];
                }
                if (i % 4 == 0 || i % 4 == 3) {
                    y[i] = -y[i];
                }
            }
            genEps(0, 0, 9, x, y);
        }       
        {
            int[] x, y;
            x = new int[3];
            y = new int[3];
            x[0] = y[0] = -999999990;
            x[1] = y[1] = 0;
            x[2] = y[2] = 999999990;
            genEps(999999990, 999999990, 3, x, y);
        }   
        
    }

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

}
