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 long MAXK = 1000L * 1000 * 1000 * 1000 * 1000 * 1000;

    void print(int a, int b, int c, int d, long k) 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 + " " + k);
        out.close();
    }


    void stableTest() throws IOException {
    	int A = rnd.nextInt(100) + 1;
	    int B = rnd.nextInt(1000 / A) + 1;
		int C = A * (B - 1);
		int D = 1000;
		long k = MAXK;
		print(A, B, C, D, k);
	}

	void becomeDTest() throws IOException {
    	int A = rnd.nextInt(1000) + 1;
		int D = rnd.nextInt(1000 - A) + A;
		int C = rnd.nextInt(1001);
		int B = rnd.nextInt(1000) + 1;

		while (A * B - C <= A) {
			B = rnd.nextInt(1000) + 1;
		}			
 		long k = MAXK;
		print(A, B, C, D, k);
	}

	void becomeZeroTest() throws IOException {
    	int A = rnd.nextInt(1000) + 1;
		int D = rnd.nextInt(1000 - A) + A;
		int C = rnd.nextInt(1001);
		int B = rnd.nextInt(1000) + 1;

		while (A * B - C >= A) {
			C = rnd.nextInt(1001);
			B = rnd.nextInt(1000) + 1;
		}			
 		long k = MAXK;
		print(A, B, C, D, k);
	}

	void growingTest() throws IOException {
    	while (1 == 1) {
			int A = rnd.nextInt(1000) + 1;
			int D = 1000;
			int C = rnd.nextInt(1001);
			int B = rnd.nextInt(1000) + 1;

			while (A * B - C <= A) {
				C = rnd.nextInt(1001);
				B = rnd.nextInt(1000) + 1;
			}		
			int realA = A;	
			int k = 0;	  
			while (A * B - C < D) {
				k++;
				A = A * B - C;
			}
			k--;
			if (k > 0) {	
				print(realA, B, C, D, k);
				break;
			}
		}
	}

	void fallingTest() throws IOException {

    	while (1 == 1) {
			int A = rnd.nextInt(1000) + 1;
			int D = 1000;
			int C = rnd.nextInt(1001);
			int B = rnd.nextInt(1000) + 1;

			while (A * B - C >= A) {
				C = rnd.nextInt(1001);
				B = rnd.nextInt(1000) + 1;
			}		
			
			int realA = A;
			int k = 0;	  
			while (A * B - C > 0) {
				k++;
				A = A * B - C;
			}
			k--;
			
			if (k > 0) {	    	
				print(realA, B, C, D, k);
				break;
			}
		}
	}



    void genSimple() throws IOException {
        print(1, 3, 1, 5, 2);
        print(1, 2, 0, 4, 3);
		print(1, 2, 3, 5, 2);
              
    }



    public void generate() throws IOException {
        new File("../tests").mkdir();
        tNumber = 1;
        genSimple();
        rnd = new Random(313131311);
           
		print(1, 2, 3, 5, 2);
        print(1000, 1, 1, 1000, 999);
        print(1, 3, 1, 100, 4);
        print(1, 3, 1, 1000, 6);
        print(1, 3, 1, 1000, 7);
        print(500, 2, 500, 1000, 1000);
        print(700, 2, 700, 1000, 1000);
        print(700, 2, 700, 700, 1000);
        print(1, 3, 1, 1000, 1000000000);
        print(1, 1000, 1000, 1000, 1000);
        print(1000, 1000, 1000, 1000, MAXK);
        print(1000, 1, 1000, 1000, 1000);
        print(1, 2, 0, 1000, 9);
        print(1, 2, 0, 1000, 10);
        print(1, 1, 0, 1, 100000000);
        print(1000, 1, 1, 1000, 1000);
        print(1000, 1, 1, 1000, MAXK);
        print(1, 3, 1, 1000, MAXK);
        print(1, 3, 2, 1000, MAXK);
        print(1, 1000, 0, 1000, MAXK);
        print(1, 1000, 0, 996, MAXK);

        print(500, 2, 500, 1000, MAXK);
        print(700, 2, 700, 1000, MAXK);
        print(2, 3, 2, 1000, MAXK);
        print(999, 2, 1000, 1000, MAXK);
        print(1000, 1, 1, 1000, 331);

     
		for (int i = 0; i < 5; i++) {
			stableTest();
			becomeDTest(); 	
			becomeZeroTest();
			growingTest();
			fallingTest();
		}

    }

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