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

public class TestGen {
    static final int MX = 100_000_000;
    static final long MAGIC = 77_068_225L;
    static final int MAXN = 100_000;

    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, long d, int[] x, int[] y) throws IOException {
        PrintWriter pw = new PrintWriter(String.format("../tests/%02d", ++testCount));
        System.out.println(testCount);
        pw.println(n + " " + d);
        for (int i = 0; i < n; i++) {
            pw.println(x[i] + " " + y[i]);
        }
        pw.close();     
    }

    void write(long d, TreeSet<Point> st) throws IOException {
        PrintWriter pw = new PrintWriter(String.format("../tests/%02d", ++testCount));
        System.out.println(testCount);
        pw.println(st.size() + " " + d);
        for (Point p : st) {
            pw.println(p.x + " " + p.y);
        }
        pw.close();     
    }

    void genSample() throws IOException {
        int n = 9;
        long d = 1;
        int x[] = new int[n];
        int y[] = new int[n];
        x[0] = 0; y[0] = 0;
        x[1] = 1; y[1] = 0;
        x[2] = 1; y[2] = 1;
        x[3] = 0; y[3] = 1;
        x[4] =-1; y[4] = 1;
        x[5] =-1; y[5] = 0;
        x[6] =-1; y[6] =-1;
        x[7] = 0; y[7] =-1;
        x[8] = 1; y[8] =-1;
        write(n, d, x, y);
    }

    class Point implements Comparable<Point> {
        int x, y;

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

        @Override
        public int compareTo(Point p) {
            if (x != p.x) {
                return Integer.compare(x, p.x);
            }
            return Integer.compare(y, p.y);
        }
    }

    TreeSet<Point> st = new TreeSet<Point>();
    ArrayList<Integer> xs = new ArrayList<Integer>();
    ArrayList<Integer> ys = new ArrayList<Integer>();

    void genTests(int x0, int y0, int n, long d) {
        int x[] = new int[n];
        int y[] = new int[n];
        st.add(new Point(x0, y0));
        x[0] = x0;
        y[0] = y0;
        for (int i = 1; i < n; i++) {
            while (true) {
                int p = random.nextInt(i);
                int px = x[p];
                int py = y[p];
                int k = random.nextInt(xs.size());
                int k1 = random.nextInt(2);
                if (k1 == 0) k1 = -1;
                int k2 = random.nextInt(2);
                if (k2 == 0) k2 = -1;
                int nx = px + k1 * xs.get(k);
                int ny = py + k2 * ys.get(k);
                if (Math.max(Math.abs(nx), Math.abs(ny)) <= MX && !st.contains(new Point(nx, ny))) {
                    x[i] = nx;
                    y[i] = ny;
                    st.add(new Point(nx, ny));
                    break;
                }
            }
        }
    }

    int mySqrt(long d) {
        int res = (int)Math.sqrt(d + 0.5);
        if (1L * res * res != d) return -1;
        return res;
    }

    void genTests(int k, int n, long d) throws IOException {        
        st.clear();
        xs.clear();
        ys.clear();
        
        for (int x = 0; 1L * x * x <= d; x++) {
            int y = mySqrt(d - 1L * x * x);
            if (y != -1) {
                xs.add(x);
                ys.add(y);
                xs.add(y);
                ys.add(x);
            }   
        }

        for (int i = 0; i < k; i++) {
            while (true) {
                int x0 = random.nextInt(100000);
                int y0 = random.nextInt(100000);
                if (st.contains(new Point(x0, y0))) continue;
                genTests(x0, y0, n, d);
                break;
            }
        }
        write(d, st);
    }

    void run() throws IOException {
        new File("../tests").mkdir();
                                                                    
        genSample();    
        genTests(1, 1, MX);
        genTests(1, 5, 25);
        genTests(2, 10, 25);
        genTests(4, 15, 325);
        genTests(1, 70, 1);
        genTests(2, 57, 2);
        genTests(187, 4, 4_005_625);
        genTests(3, 333, MAGIC);
        genTests(1, MAXN, MAGIC);
        genTests(1, MAXN, MAGIC);
        genTests(2, MAXN / 2, MAGIC);
        genTests(5, MAXN / 5, MAGIC);
        genTests(100, MAXN / 100, MAGIC);
        genTests(1000, MAXN / 1000, MAGIC);
        genTests(50000, MAXN / 50000, MAGIC);
        genTests(1, MAXN, MX);
        genTests(1, MAXN, 325);
    }

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

}
