// Tests generator for Painting problem
// Author : Vladimir Ulyantsev, ulyantsev@rain.ifmo.ru

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

public class PaintingTestsGen 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 PaintingTestsGen()).start();
    }

    PrintWriter out;

    Random random = new Random(6466403L);

    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);
        }
    }


    final int MAXN = 100;

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

    void gen(int w, int h, int l, int k) {
    	open();
    	
    	out.println(w + " " + h + " " + l + " " + k);

    	close();
    }

    public void solve() throws IOException {
       	for (int k = 0; k <= 6; k++) {
       		for (int w = 0; w <= 1; w++) {
       			for (int h = 0; h <= 1; h++) {
       				for (int l = 0; l <= 1; l++) {
       					gen(w == 0 ? 1 : 2 + random.nextInt(MAXN / 10), 
       						h == 0 ? 1 : 2 + random.nextInt(MAXN / 10),
       						l == 0 ? 1 : 2 + random.nextInt(MAXN / 10), k);
       				}
       			}
       		}
    	}

    	for (int k = 0; k <= 6; k++) {
       		for (int w = 0; w <= 1; w++) {
       			for (int h = 0; h <= 1; h++) {
       				for (int l = 0; l <= 1; l++) {
       					if (w + h + l > 0 && random.nextInt(2) > 0)
       						gen(w == 0 ? 1 : 2 + random.nextInt(MAXN), 
       							h == 0 ? 1 : 2 + random.nextInt(MAXN),
       							l == 0 ? 1 : 2 + random.nextInt(MAXN), k);
       				}
       			}
       		}
    	}

    	for (int k = 0; k <= 6; k++) {
    		gen(MAXN, MAXN, MAXN, k);
    	}
    }

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