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

public class TestsGen {
	static int testcount = 0;

	static int MAXN = (int) 1e3;
	static int MAXM = (int) 1e5;
	static int MAXW = (int) 1e9;

	static Random random = new Random(4897344);

	static void write() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));

		out.close();
	}

	static void write1() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = 447;
		int m = n * (n - 1) / 2;
		out.println(n + " " + m);
		out.println(MAXW);
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				out.println((i + 1) + " " + (j + 1) + " " + (MAXW - 1));
			}
		}
		out.close();
	}

	static void write2() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = 447;
		int m = n * (n - 1) / 2;
		out.println(n + " " + m);
		out.println(MAXW);
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				out.println((i + 1) + " " + (j + 1) + " " + (MAXW));
			}
		}
		out.close();
	}

	static void write5() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = MAXN;
		int m = 447 * (446) / 2;
		out.println(n + " " + m);
		out.println(MAXW);
		for (int i = 0; i < 447; i++) {
			for (int j = i + 1; j < 447; j++) {
				out.println((i + 1) + " " + (j + 1) + " " + (MAXW));
			}
		}
		out.close();
	}

	static void write6() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = MAXN;
		int m = 447 * (446) / 2;
		out.println(n + " " + m);
		out.println(MAXW);
		for (int i = 0; i < 446; i++) {
			for (int j = i + 1; j < 446; j++) {
				out.println((i + 1) + " " + (j + 1) + " " + (MAXW));
			}
		}
		for (int i = 0; i < 446; i++) {
			out.println(1000 + " " + (i + 1) + " " + MAXW);
		}
		out.close();
	}

	static void write7() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = MAXN;
		int m = 447 * (446) / 2;
		out.println(n + " " + m);
		out.println(MAXW);
		for (int i = 0; i < 446; i++) {
			for (int j = i + 1; j < 446; j++) {
				out.println((i + 1) + " " + (j + 1) + " " + (MAXW - 1));
			}
		}
		for (int i = 445; i >= 0; i--) {
			out.println(1000 + " " + (i + 1) + " " + MAXW);
		}
		out.close();
	}

	static void write8() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = MAXN;
		int m = 447 * (446) / 2;
		out.println(n + " " + m);
		out.println(MAXW);
		for (int i = 0; i < 446; i++) {
			for (int j = i + 1; j < 446; j++) {
				out.println((i + 1) + " " + (j + 1) + " " + (MAXW - 1));
			}
		}
		for (int i = 0; i < 446; i++) {
			out.println(1000 + " " + (i + 1) + " " + (MAXW - 1));
		}
		out.close();
	}

	static void write3() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = MAXN;
		int m = 0;
		out.println(n + " " + m);
		out.println(MAXM);
		out.close();
	}

	static void write4() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int n = MAXN;
		int m = 0;
		out.println(n + " " + m);
		out.println(1);
		out.close();
	}

	static void writeBound(int n, int m) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int[][] tab = new int[n][n];
		int[] x = new int[m];
		int[] y = new int[m];
		int[] w = new int[m];
		Edge[] e = new Edge[m];
		for (int i = 0; i < m; i++) {
			x[i] = random.nextInt(n);
			y[i] = random.nextInt(n);
			while (tab[x[i]][y[i]] > 0) {
				x[i] = random.nextInt(n);
				y[i] = random.nextInt(n);
			}
			w[i] = random.nextInt(MAXW) + 1;
			tab[x[i]][y[i]] = w[i];
			tab[y[i]][x[i]] = w[i];
			e[i] = new Edge(x[i], y[i], w[i]);
		}
		Arrays.sort(e);
		SNM a = new SNM(n);
		{
			int i = m;
			while (i > 0 && a.get(0) != a.get(n - 1)) {
				i--;
				if (a.get(e[i].x) != a.get(e[i].y)) {
					a.union(e[i].x, e[i].y);
				}
			}
			out.println(n + " " + m);
			out.println(e[i].w + 1);
		}
		for (int i = 0; i < m; i++) {
			out.println((x[i] + 1) + " " + (y[i] + 1) + " " + w[i]);
		}
		out.close();
	}

	static void writeRand(int n, int m) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		int[][] tab = new int[n][n];
		int[] x = new int[m];
		int[] y = new int[m];
		int[] w = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = random.nextInt(n);
			y[i] = random.nextInt(n);
			while (tab[x[i]][y[i]] > 0) {
				x[i] = random.nextInt(n);
				y[i] = random.nextInt(n);
			}
			w[i] = random.nextInt(MAXW) + 1;
			tab[x[i]][y[i]] = w[i];
			tab[y[i]][x[i]] = w[i];
		}
		out.println(n + " " + m);
		out.println(random.nextInt(MAXW) + 1);
		for (int i = 0; i < m; i++) {
			out.println((x[i] + 1) + " " + (y[i] + 1) + " " + w[i]);
		}
		out.close();
	}
	
	public static void main(String[] args) throws IOException {
		while (new File(String.format("%02d.t", testcount + 1)).exists()) {
			testcount++;
		}

		write1();
		write2();
		write3();
		write4();
		write5();
		write6();
		write7();
		write8();
		writeRand(MAXN, MAXM);
		writeRand(MAXN, MAXM);
		for (int i = 0; i < 10; i++) {
			int n = random.nextInt(MAXN - 1) + 2;
			int m = Math.min(n * (n - 1) / 2, random.nextInt(MAXM + 1));
			writeRand(n, m);
		}
		for (int i = 0; i < 10; i++) {
			int n = random.nextInt(MAXN - 1) + 2;
			int m = Math.min(n * (n - 1) / 2, random.nextInt(MAXM + 1));
			writeBound(n, m);
		}
	}

}

class Edge implements Comparable<Edge> {
	int x, y, w;

	Edge(int a, int b, int c) {
		x = a;
		y = b;
		w = c;
	}

	@Override
	public int compareTo(Edge o) {
		if (w < o.w)
			return -1;
		if (w > o.w)
			return 1;
		return 0;
	}
}

class SNM {
	int[] a;

	SNM(int n) {
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i;
		}
	}

	int get(int i) {
		if (a[i] != i) {
			a[i] = get(a[i]);
		}
		return a[i];
	}

	void union(int a, int b) {
		a = get(a);
		b = get(b);
		this.a[a] = b;
	}
}