/**
 * Created by GShark on 20.11.2014.
 */
import java.io.*;
import java.util.*;

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

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    int tNumber;
    Random rnd;
    final int MAXN = 500;
    final int MAXD = 1_000_000_000;

    int rand(int n) {
        return rnd.nextInt(n);
    }

    int sand(int n) {
        return rand(2 * n + 1) - n ;
    }

    void print(int a, int b, int c, int d) throws IOException {
        System.err.println(tNumber);
        if (tNumber < 10) {
            out = new PrintWriter("../tests/0" + tNumber);
        } else {
            out = new PrintWriter("../tests/" + tNumber);
        }
        tNumber++;
        out.println(a + " " + b + " " + c + " " + d);
        out.close();
    }

    // here starts gens

    void genSamples() throws IOException {
        print(1, 1, 1, 3);
        print(1, 2, 3, 6);
        print(1, 2, 3, 7);
        print(1, -1, -2, 6);
    }

    void genSimples() throws IOException {
        print(-98, -21, 99, 19846);
        print(-29, -15, 31, 2027);
        print(-24, -59, 61, 7778);
        print(0, 0, 0, 0);
    }

    void genRand(int maxn) throws IOException {
        print(sand(maxn), sand(maxn), sand(maxn), sand(maxn));
    }

    void genRandCorrect(int maxn, int x) throws IOException {
        while(true) {
            int a = sand(maxn);
            int b = sand(maxn);
            int c = sand(maxn);
            long a1 = 1, b1 = 1, c1 = 1, d1;
            for (int i = 0; i < x; i++) {
                a1 *= a;
                b1 *= b;
                c1 *= c;
            }
            d1 = a1 + b1 + c1;
            if (-MAXD <= d1 && d1 <= MAXD) {
                int d = (int) d1;
                print(a, b, c, d);
                return;
            }
        }
    }

    void genCubeBad(int maxn) throws IOException {
        int a = sand(maxn);
        int b = sand(2);
        print(a, b, -a, b);
        a = sand(maxn);
        b = sand(2);
        print(b, a, -a, b);
        a = sand(maxn);
        b = sand(2);
        print(a, -a, b, b);
    }

    void genMax() throws IOException {
        print(MAXN, MAXN, MAXN, MAXD);
        print(MAXN, -MAXN, MAXN, MAXD);
        print(-MAXN, -MAXN, -MAXN, -MAXD);
        print(MAXN, -MAXN, -MAXN, -MAXD);
        print(MAXN, 0, -MAXN, 0);
        print(MAXN, -MAXN, 1, 1);
    }

    //the end of the gens

    public void generate() throws IOException {
        new File("../tests").mkdir();
        tNumber = 1;
        rnd = new Random(388282447);

        genSamples();
        genSimples();
        genCubeBad(10);
        genRand(15);
        genRandCorrect(13, 1);
        genRandCorrect(14, 2);
        genRandCorrect(15, 3);

        for (int i = 0; i < 5; i++) {
            genCubeBad(MAXN);
            genRand(MAXN);
            genRandCorrect(MAXN, 1);
            genRandCorrect(MAXN, 2);
            genRandCorrect(MAXN, 3);
        }

        genMax();
    }

    public void run() throws IOException {
        Locale.setDefault(Locale.US);
        generate();
    }
}
