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

public class TestsGen implements Runnable {
    public static void main(String[] args) {
        if (args.length < 1) {
        	for (I = 1; (new File(getName(I) + ".t")).exists(); I++);
        } else {
            I = Integer.parseInt(args[0]);
        }
        new Thread(new TestsGen()).start();
    }

    PrintWriter out;

    Random rand = new Random(64395786L);

    static int I;

    static String getName(int i) {
    	return ((i < 10) ? "0" : "") + i;
    }
    
    void open() {
        try {
        	System.out.println("Generating test " + I);
            out = new PrintWriter(getName(I));
        } catch (FileNotFoundException e) {        	
        	e.printStackTrace();
        	System.exit(-1);
        }
    }

    void close() {
        out.close();
        I++;
    }

    int rand(int l, int r) {
        return l + rand.nextInt(r - l + 1);
    }

    String randString(int len, String alpha) {
        StringBuilder ans = new StringBuilder();
        int k = alpha.length();
        for (int i = 0; i < len; i++) {
            ans.append(alpha.charAt(rand.nextInt(k)));
        }
        return ans.toString();
    }

     
    final int MAX = 1000000;
    
    void genRandTest() {
    	genTest(rand(1, MAX), rand(1, MAX), rand(1, MAX), rand(1, MAX));    	
    }
    
    void genTest(int d, int h1, int h2, int l) {
    	open();
    	out.println(d + " " + h1 + " " + h2 + " " + l);
    	close();
    }
    
    
    public void solve() throws IOException {
    	genTest(1, 1, 1, 1);
    	genTest(2, 1, 1, 1);
    	genTest(MAX, 1, 1, 1);
    	genTest(1, MAX, 1, 1);
    	genTest(1, MAX, MAX, 1);
    	genTest(2, 5, 5, 1);
    	for (int i = 0; i < 5; i++) {
    		int h = rand(1, 100);
    		int d = rand(1, 100);
    		genTest(d, h, h, d);
    	}
    	genTest(MAX, MAX, MAX, MAX);
    	genTest(1, MAX, MAX, MAX);
    	genTest(MAX, MAX, MAX, 1);
    	genTest(1, MAX, MAX, MAX - 1);
    	genTest(260148, 947075, 1000000, 52925);
    	for (int i = 0; i < 10; i++) {
    		while (true) {    			
    			int v = rand(1, 1000);
    			int u = rand(1, 1000);
    			int d = 2 * u * v;
    			int l = Math.abs(u * u - v * v);
    			if (d > MAX || l >= MAX) continue;
    			genTest(d, MAX - l, MAX, l);
    			break;
    		}
    	}
    	
    	for (int i = 0; i < 10; i++) {
    		while (true) {
    			int d = rand(3, 100);
    			int l = rand(3, d);
    			if ((d * d - l * l) % l == 0) continue;
    			int a = Math.max((int)Math.floor((d * d - l * l + 0.0) / (2 * l)), 0);

    			int h = rand(a + 10, MAX);
    			genTest(d, rand(h - a, h), h, l);
    			break;
    		}
    	}
    	
    	
    	for (int i = 0; i < 20; i++) {
    		genRandTest();
    	}
    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
}
