import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class TestGen {
	class Edge {
		int a, b, c;

		public Edge(int a, int b, int c) {
			super();
			this.a = a;
			this.b = b;
			if (a == b) {
				throw new AssertionError();
			}
			this.c = c;
		}

	}

	class Test {
		int n;
		int s, t1, t2;
		List<Edge> es;

		public Test(int n, int s, int t1, int t2, ArrayList<Edge> es) {
			this.n = n;
			this.s = s;
			this.t1 = t1;
			this.t2 = t2;
			this.es = es;
		}

		public Test(int n, int s, int t1, int t2, Edge... es) {
			super();
			this.n = n;
			this.s = s;
			this.t1 = t1;
			this.t2 = t2;
			this.es = Arrays.asList(es);
		}

	}

	class DSU {
		int[] p, r;

		public DSU(int n) {
			p = new int[n];
			for (int i = 0; i < p.length; i++) {
				p[i] = i;
			}
			r = new int[n];
		}

		int get(int x) {
			if (p[x] == x)
				return x;
			return p[x] = get(p[x]);
		}

		void union(int a, int b) {
			a = get(a);
			b = get(b);
			if (a == b)
				return;
			if (r[a] > r[b]) {
				p[b] = a;
			} else if (r[a] < r[b]) {
				p[a] = b;
			} else {
				p[a] = b;
				r[b]++;
			}
		}
	}

	private int testCount = 1;

	private void write(Test t) {
		try {
			++testCount;
			String filename = testCount / 10 + "" + testCount % 10;
			PrintWriter out = new PrintWriter(filename);
			out.println(t.n + " " + t.es.size());
			for (Edge e : t.es) {
				out.println((e.a + 1) + " " + (e.b + 1) + " " + e.c);
			}
			out.println((t.t1 + 1) + " " + (t.t2 + 1) + " " + (t.s + 1));
			out.flush();
			out.close();
			System.err.println(testCount);
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
	}

	void myAssert(boolean b) {
		if (!b)
			throw new AssertionError();
	}

	static Random rand = new Random(2);
	final int MAXN = (int) 1e5;
	final int MAXM = (int) 1e5;
	final int MAXW = (int) 1e9;

	public void run() throws IOException {
		for (int i = 0; i < 10; i++) {
			write(genRand(rand.nextInt(10) +2, rand.nextInt(30) + 1, rand.nextInt(25) + 1));
		}
		write(genRand(10, 30, 25, 7, 5, 7));
		write(genRand(10, 30, 25, 3, 1, 1));
		for (int i = 0; i < 10; i++) {
			write(genRand(rand.nextInt(MAXN  - 1) + 2, rand.nextInt(MAXM) + 1, MAXW));
		}
		write(genRand(MAXN, MAXM, MAXW));
		write(genRand((int) Math.sqrt(MAXM), MAXM, MAXW));
	}

	Test genRand(int n, int m, int max) {
		int t1 = rand.nextInt(n);
		int t2;
		do {
			t2 = rand.nextInt(n);
		} while (t2 == t1);
		int s = rand.nextInt(n);
		return genRand(n, m, max, t1, t2, s);
	}

	Test genRand(int n, int m, int max, int t1, int t2, int s) {
		DSU dsu = new DSU(n);
		ArrayList<Edge> e = new ArrayList<Edge>();
		for (int i = 0; i < n - 1; i++) {
			int a, b;
			do {
				a = rand.nextInt(n);
				b = rand.nextInt(n);
			} while (dsu.get(a) == dsu.get(b));
			e.add(new Edge(a, b, rand.nextInt(max) + 1));
			dsu.union(a, b);
		}
		m -= n - 1;
		for (int i = 0; i < m; i++) {
			int a, b;
			do {
				a = rand.nextInt(n);
				b = rand.nextInt(n);
			} while (a == b);
			e.add(new Edge(a, b, rand.nextInt(max) + 1));
		}
		return new Test(n, s, t1, t2, e);
	}

	public static void main(String[] args) throws IOException {
		new TestGen().run();
	}

}
