import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.File;
import java.util.*;

public class Tests {
    int testNo = 1;

    public void printTest(int maxp, int maxv, int p, int v) {
        PrintWriter out = null;
        try {
            new File("tests").mkdir();
            out = new PrintWriter("tests/" + testNo / 100 + testNo % 100 / 10 + testNo % 10);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return;
        }

        out.println(maxp + " " + maxv + " " + encode(p, maxp) + " " + encode(v, maxv));
        out.println("Note, p and v in input are shifted by 239 to ensure that if read by participant input is not decoded");

        out.close();
        testNo++;
    }

    int encode(int p, int n) {
        return ((p - 239) % (n + 1) + (n + 1)) % (n + 1);
    }

    Random rnd = new Random(219238948812818L);

    final static int MAX = 100000;

    public void run() {
        printTest(2, 2, 1, 1);
        for (int i = 2; i <= 2; i++) {
            for (int j = 2; j <= 2; j++) {
                for (int k = 0; k <= i; k++) {
                    for (int l = 0; l <= j; l++) {
                        printTest(i, j, k, l);
                    }
                }
            }
        }

        for (int maxp : new int[]{1, 100, 1000, 99999, 100000}) {
            for (int maxv : new int[]{1, 100, 1000, 99999, 100000}) {
                printTest(maxp, maxv, 0, 0);
                printTest(maxp, maxv, 0, maxv);
                printTest(maxp, maxv, maxp, 0);
                printTest(maxp, maxv, maxp, maxv);
                if (maxp > 1 || maxv > 1) {
                    printTest(maxp, maxv, maxp / 2, maxv / 2);
                    printTest(maxp, maxv, rnd.nextInt(maxp + 1), rnd.nextInt(maxv + 1));
                }
            }
        }

        for (int i = 0; i < 10; i++) {
            int maxp = rnd.nextInt(MAX) + 1;
            int maxv = rnd.nextInt(MAX) + 1;
            printTest(maxp, maxv, rnd.nextInt(maxp + 1), rnd.nextInt(maxv + 1));
        }
    }

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

