import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

public class Tests {
    final int MIN_N = 1;
    final int MAX_N = 3000;
    final int MAX_C = (int) 1e9;

    int testNo = 0;
    PrintWriter out;
    static PrintWriter descriptions;
    Random random = new Random(7023842358235832895L);

    void beginTest(String description, Object... args) {
        ++testNo;
        descriptions.format("%02d: %s\n", testNo, String.format(description, args));
        descriptions.flush();
        System.out.format("%02d: %s\n", testNo, String.format(description, args));
        try {
            out = new PrintWriter(String.format("tests/%02d", testNo));
        } catch (FileNotFoundException e) {
            throw new AssertionError(e);
        }
    }

    private void assertBetween(int min, long value, int max) {
        assert min <= value && value <= max : value + " not between "  + min + " and " + max;
    }

    public void run() throws IOException {
        sampleTests();
        smallTests();
        maxTests();
        randomTests();
    }

    private void maxTests() {
        writeTest("Absolute max test", MAX_N, MAX_C, MAX_C);
        for (int i = 0; i < 10; i++) {
            writeTest("Max test " + (i + 1), MAX_N, random.nextInt(MAX_C + 1), random.nextInt(MAX_C + 1));
        }
    }

    private void smallTests() {
        int index = 1;
        for (int i = 2; i <= 4; i++) {
            for (int j = 0; j <= 3; j++) {
                for (int k = 0; k <= 4; k++)
                    writeTest("Small test " + (index++), i, j, k);
            }
        }
    }

    public void sampleTests() {
        writeTest("Sample test 1", 1, 1, 2);
        writeTest("Sample test 2", 10, 10, 10);
    }

    private void randomTests() {
        for (int i = 0; i < 20; i++) {
            writeTest("Random test " + (i + 1), random.nextInt(MAX_N) + 1, random.nextInt(MAX_C + 1), random.nextInt(MAX_C + 1));
        }
        for (int i = 0; i < 5; i++) {
            int n = random.nextInt(MAX_N) + 1;
            int dTix = random.nextInt(n);
            int sTix = random.nextInt(n - dTix);
            writeTest("All fulfilled " + (i + 1), n, dTix, sTix);
        }
    }

    private void writeTest(String description, int count, int dblTix, int sngTix) {
        beginTest(description);
        endTest(count, dblTix, sngTix);
    }

    private void endTest(int count, int dblTix, int sngTix) {
        validateTest(count, dblTix, sngTix);

        out.println(count + " " + dblTix + " " + sngTix);
        out.close();
    }

    private void validateTest(int count, int dblTix, int sngTix) {
        assertBetween(MIN_N, count, MAX_N);
        assertBetween(0, dblTix, MAX_C);
        assertBetween(0, sngTix, MAX_C);
    }

    public static void main(String[] args) throws IOException {
        descriptions = new PrintWriter("tests/tests.lst");
        new Tests().run();
        descriptions.close();
    }
}
