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

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

public class TestGen {
        
    static PrintWriter out;
    static Random rnd = new Random(0);
    static int tNumber;
    static void printTest(ArrayList<Point> points) throws IOException {
        if (tNumber < 10)
            out = new PrintWriter("../tests/0" + tNumber);
        else
            out = new PrintWriter("../tests/" + tNumber);
        tNumber++;                     
        out.println(points.size());
        for (int i = 0; i < points.size(); i++) {
            out.println(points.get(i).x + " " + points.get(i).y);
        }
        out.close();
    }
    static void genSample() throws FileNotFoundException {
        out = new PrintWriter("../tests/01");                       
        out.println("7\r\n2 6\r\n5 6\r\n2 5\r\n2 2\r\n6 8\r\n2 2\r\n0 2");
        out.close();
    }

    static void genSimple() throws FileNotFoundException, IOException {
        ArrayList <Point> a = new ArrayList<Point>();
        a.add(new Point(0, 0));
        printTest(a);

        a.set(0, new Point(1000000000, 1000000000));
        printTest(a);
   }

    static int randFromTo(int l, int r) {
        return rnd.nextInt(r - l + 1) + l;      
    }
    static ArrayList<Point> genChain(int n, int mx) {
        ArrayList<Integer> tmp = new ArrayList<Integer>();
        for (int i = 0; i < n + 1; i++)
            tmp.add(randFromTo(0, mx));
        Collections.sort(tmp);
       	ArrayList<Point> ans = new ArrayList<Point>();
        for (int i = 0; i < n; i++) {
            Point t = new Point(tmp.get(i), tmp.get(i + 1));
            ans.add(t);                 
        }
        Collections.shuffle(ans);
        return ans;
    }
    static ArrayList<Point> genPoints(int n, int mx) {
        int cnt = randFromTo(1, n / 2);
        ArrayList<Integer> tmp = new ArrayList<Integer>();
        for (int i = 0; i < cnt - 1; i++)
            tmp.add(randFromTo(1, n));
        Collections.sort(tmp);
        ArrayList<Point> ans = new ArrayList<Point>();        
        int now = 0, i = 0;;
        for (; i < tmp.size(); i++) {
            ArrayList<Point> t = genChain(tmp.get(i) - now, mx);
            for (int j = 0; j < t.size(); j++)
                ans.add(t.get(j));
            now = tmp.get(i);
        }
        ArrayList<Point> t = genChain(n - now, mx);
        for (int j = 0; j < t.size(); j++)
            ans.add(t.get(j));          
        Collections.shuffle(ans);                   
        return ans;             
    }


    public static void main(String[] args) throws IOException {
        genSample();
        tNumber = 2;
        genSimple();                                           
        for (int i = 0; i < 10; i++)
            printTest(genPoints(100, 1000));
        for (int i = 0; i < 10; i++)
            printTest(genPoints(1000, 100000));
        for (int i = 0; i < 20; i++)
            printTest(genPoints(100000, 1000000000));               
    }
}
