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

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

    public int done = 0;
    ArrayList<String> data = new ArrayList<String>();

    final int MAXN = 1000;
    final int MAXTIME = (int) 1e4;

    public void print() throws IOException {
        done++;
        System.err.println(done);
        PrintWriter out;
        if (done < 10)
            out = new PrintWriter("0" + String.valueOf(done));
        else
            out = new PrintWriter(String.valueOf(done));

        for (int i = 0; i < data.size(); i++)
            out.println(data.get(i));
        out.println();
        out.close();
    }

    public void genRand(int maxN, int maxM, int maxK, int maxTime)
            throws IOException {
        data.clear();
        int curN = nextInt(1, maxN);
        int curM = nextInt(1, maxM);
        int curTime = nextInt(1, 10);
        int curK = 0;
        for (int i = 0; i < maxK && curTime < maxTime; i++) {
            curK++;
            data.add(curTime + " " + nextInt(1, maxTime) + " " + nextInt(0, 1));
            curTime = nextInt(curTime + 1, maxTime);
        }
        data.add(0, curN + " " + curM + " " + curK);
        print();
    }

    public int nextInt(int low, int high) {
        int base = high - low + 1;
        int val = rnd.nextInt();
        val %= base;
        while (val < 0)
            val += base;
        val += low;
        return val;
    }

    public void genWrongCheck(int n) throws IOException {
        data.clear();
        data.add(n + " " + 1 + " " + (n + 1));
        for (int i = 0; i < n - 2; i++) {
            data.add((i + 1) + " " + MAXTIME + " " + 0);
        }
        data.add((n - 1) + " " + MAXTIME + " " + 1);
        data.add(n + " " + MAXTIME + " " + 1);
        data.add((n + 1) + " " + MAXTIME + " " + 0);
        print();
    }

    public void genMax(int code) throws IOException {
        data.clear();
        data.add(MAXN + " " + MAXN + " " + MAXN);
        int step = MAXTIME / MAXN;
        int l = 0;
        int r = 1;
        if (code == 0 || code == 1) {
            l = code;
            r = code;
        }
        for (int i = 0; i < MAXN; i++) {
            data.add((step * i + nextInt(1, step)) + " " + nextInt(1, step * 3)
                    + " " + nextInt(l, r));
        }
        print();
    }

    public void genAllLate(int low) throws IOException {
        data.clear();
        data.add(MAXN + " " + MAXN + " " + MAXN);
        for (int i = MAXTIME - MAXN + 1; i <= MAXTIME; i++) {
            data.add(i + " " + nextInt(low, MAXTIME) + " " + nextInt(0, 1));
        }
        print();
    }

    Random rnd;

    public void run() {
        try {
            rnd = new Random(346);

            genRand(10, 10, 10, 100);

            genRand(10, 10, 10, MAXTIME);

            genRand(100, 100, 100, 1000);

            genRand(100, 100, 100, MAXTIME);
            genRand(100, 100, 100, MAXTIME);

            for (int i = 0; i < 5; i++) {
                genRand(1000, 1000, 1000, MAXTIME);
            }

            genWrongCheck(10);
            genWrongCheck(100);
            genWrongCheck(1000 - 1);

            genRand(2, 2, 1000, MAXTIME);
            genRand(2, 2, 1000, MAXTIME);

            genMax(0);
            genMax(1);

            genAllLate(1);
            genAllLate(MAXN);
            genAllLate(MAXTIME);
            while (done < 25) {
                genMax(-1);
            }

        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
