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

public class TestGen {

    static PrintWriter out;
    static Random rnd = new Random(0);
    static int tNumber;
    static void printTest(int n, int mxK, ArrayList<Integer> points) throws IOException {
        if (tNumber < 10)
            out = new PrintWriter("../tests/0" + tNumber);
        else
            out = new PrintWriter("../tests/" + tNumber);
        tNumber++;
                       
        out.println(n + " " + points.size() / 3 + "\r\n" + randFromTo(2, mxK));
        for (int i = 0; i < points.size(); i += 3)
            out.println(points.get(i) + " " + points.get(i+1) + " " + points.get(i + 2));
        out.close();
    }
    static void genSample() throws FileNotFoundException {
        out = new PrintWriter("../tests/01");       
        out.println("3 3\r\n3\r\n1 2 1\r\n2 3 1\r\n1 3 2");
        out.close();
    }
    static int randFromTo(int l, int r) {
        return rnd.nextInt(r - l + 1) + l;      
    }
    static ArrayList<Integer> genPoints(int n, int m, int maxD) {
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < m; i++) {  
            int a = randFromTo(1, n);
            int b = randFromTo(1, n);
            while (a == b)
                a = randFromTo(1, n);
            list.add(a);
            list.add(b);
            list.add(randFromTo(1, maxD));
        }
        return list;                
    }


    public static void main(String[] args) throws IOException {
        genSample();
        tNumber = 2;
        for (int i = 0; i < 5; i++) {
            printTest(10, 15, genPoints(10, 20, 50));
        }
        for (int i = 0; i < 10; i++) {
            printTest(100, 150, genPoints(100, 1000, 1000));
        }

        for (int i = 0; i < 25; i++) {
            printTest(100000 - i, 100000, genPoints(100000 - i, 200000, 10000));
        }
        
    }
}
