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

public class TestGen {
    static int nTests = 0;
    static final Random r = new Random(444444444444442L);

    static class Item {
        final int v;
        final int c;
        final int p;

        Item(int v, int c, int p) {
            this.v = v;
            this.c = c;
            this.p = p;
        }
    }

    static Item i(int v, int c, int p) {
        return new Item(v, c, p);
    }

    public static void write(int v0, Item... items) {
        try {
            PrintWriter out = new PrintWriter(String.format("%02d", nTests + 1));
            out.println(items.length + " " + v0);
            for (Item i : items) {
                out.println(i.v + " " + i.c + " " + i.p);
            }
            out.close();
            if (out.checkError()) {
                throw new IOException();
            }
            nTests++;
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public static void writeSmallRandom() {
        int n = 1 + r.nextInt(10);
        Item[] items = new Item[n];
        for (int i = 0; i < n; ++i) {
            items[i] = new Item(r.nextInt(100) + 1, r.nextInt(1001), r.nextInt(1001));
        }
        write(r.nextInt(101), items);
    }

    public static void writeLargeRandom() {
        int n = 100;
        Item[] items = new Item[n];
        for (int i = 0; i < n; ++i) {
            items[i] = new Item(r.nextInt(1000) + 1, r.nextInt(1000001), r.nextInt(1001));
        }
        write(r.nextInt(20000), items);
    }

    public static void antiPerm(int n) {
        Item[] items = new Item[n];
        for (int i = 0; i < n; ++i) {
            items[i] = new Item(1000 - i, 1000 - 2 * i, 0);
        }
        int sum = 0;
        int cost = 0;
        for (int i = n / 2; i < n; ++i) {
            sum += items[i].v;
            cost += items[i].c;
        }
        write(sum, items);
        System.out.println(cost);
    }

    public static void main(String[] args) {
        /** Sample tests **/
        /** 01 **/
        write(10, i(3, 1, 2), i(4, 1, 2), i(5, 1, 2));
        /** 02 **/
        write(10, i(3, 1, 1), i(4, 1, 2), i(5, 1, 3));

        /** Tests with one item - different cases **/
        /** 03 **/
        write(1000, i(1000, 1000000, 0));
        /** 04 **/
        write(999, i(1000, 1000000, 0));
        /** 05 **/
        write(1000000000, i(1000, 1000000, 0));
        /** 06 **/
        write(0, i(1000, 1000000, 1000));
        /** 07 **/
        write(0, i(1000, 1000000, 999));
        /** 08 **/
        write(0, i(1000, 1000000, 1000000000));
        /** 09 **/
        write(0, i(1000, 1000000, 0));

        antiPerm(42);
        antiPerm(43);
        for (int i = 0; i < 10; ++i) {
            writeSmallRandom();
        }
        for (int i = 0; i < 10; ++i) {
            writeLargeRandom();
        }
    }
}
