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

public class TestGen {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;
	int tNumber;

	class Worker {
		int l, r, c;

		public Worker(int l, int r) {
			super();
			this.l = l;
			this.r = r;
			this.c = rnd.nextInt(MAX_COST) + 1;
		}

		@Override
		public String toString() {
			return l + " " + r + " " + c;
		};

	}

	final int MAX_COST = (int) 1e4;

	class Test {
		ArrayList<Worker> w;
		int m, k;

		void printTest() throws FileNotFoundException {
			System.err.println(tNumber);
			if (tNumber < 10)
				out = new PrintWriter("../tests/0" + tNumber);
			else
				out = new PrintWriter("../tests/" + tNumber);
			tNumber++;
			calcK();
			out.println(w.size() + " " + m + " " + k);
			System.err.println(w.size());
			if (w.size() > 200000)
				throw new AssertionError();
			if (k > 1e8) {
				System.err.println(k);
				throw new AssertionError();
			}
			Collections.shuffle(w, rnd);
			for (Worker ww : w) {
				out.println(ww);
			}
			out.close();
		}

		private void calcK() {
			k = 1;
			for (Worker ww : w) {
				k = Math.max(k, ww.r);
			}
		}

		public void genFull(int m, int k, int extra, int L, int R, int maxLen) {
			w = new ArrayList<TestGen.Worker>();
			for (int i = 0; i < m + extra; i++) {
				int curR = L - 1;
				while (curR < R) {
					int curLen = rnd.nextInt(maxLen);
					int l = curR + 1;
					int r = 0;
					r = curR + curLen;
					if (r > R)
						r = R;
					if (r < l)
						r = l;
					w.add(new Worker(l, r));
					curR = r;
				}
			}
		}

		public void chimneySway(int l, int r) {
			if (r <= l)
				throw new AssertionError();
			for (Worker ww : w) {
				ww.l = Math.max(1, ww.l - l - rnd.nextInt(r - l));
				ww.r = ww.r + l + rnd.nextInt(r - l);
				if (ww.r < ww.l) {
					ww.r = ww.l;
				}
				if (ww.r > 1e8)
					ww.r = (int) 1e8;
			}
		}

		public void genRandom(int n, int m, int k) {
			this.m = m;
			w = new ArrayList<TestGen.Worker>();
			for (int i = 0; i < n; i++) {
				int l = 1 + rnd.nextInt(k);
				int r = l + rnd.nextInt(k - l + 1);
				w.add(new Worker(l, r));
			}
		}
	}

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public void solve() throws IOException {
		out = new PrintWriter("../tests/01");
		out.println("3 2 5");
		out.println("1 5 1");
		out.println("1 4 3");
		out.println("2 3 2");
		out.close();

		tNumber = 2;
		rnd = new Random(31);
		Test t = new Test();
		t.genRandom(5, 3, 4);
		t.printTest();

		for (int n : new int[] { 10, 100, 100_000 }) {
			for (int m : new int[] { 10, 100, 99_999 }) {
				t.genRandom(n, m, (int) 1e8);
				t.printTest();
			}
		}

		for (int extra : new int[] { 0, 1, 5 }) {
			for (int l : new int[] { 1, 10 }) {
				for (int r : new int[] { (int) 1e8, (int) (1e8 - 10) }) {
					for (int m : new int[] { 5, 100 }) {
						for (int maxLen : new int[] { 2 * (int) 1e5, (int) 1e8 }) {
							if (rnd.nextBoolean() || rnd.nextBoolean()) {
								continue;
							}
							t.genFull(m, (int) 1e8, extra, l, r, maxLen);
							t.printTest();
						}
					}
				}
			}
		}

		for (int extra : new int[] { 0, 1, 5 }) {
			for (int l : new int[] { 1, 10 }) {
				for (int r : new int[] { (int) 1e8, (int) (1e8 - 10) }) {
					for (int m : new int[] { 5, 100, 10 }) {
						for (int maxLen : new int[] { 2 * (int) 1e5, (int) 1e8 }) {
							if (rnd.nextBoolean() || rnd.nextBoolean()) {
								continue;
							}
							t.genFull(m, (int) 1e8, extra, l, r, maxLen);
							t.chimneySway(0, 10);
							t.printTest();
						}
					}
				}
			}
		}

		for (int extra : new int[] { 0, 1, 5 }) {
			for (int l : new int[] { 1, 10 }) {
				for (int r : new int[] { (int) 1e8, (int) (1e8 - 10) }) {
					for (int m : new int[] { 5, 100, 10 }) {
						for (int maxLen : new int[] { 2 * (int) 1e5, (int) 1e8 }) {
							if (rnd.nextBoolean() || rnd.nextBoolean()) {
								continue;
							}
							t.genFull(m, (int) 1e8, extra, l, r, maxLen);
							t.chimneySway(-10, 0);
							t.printTest();
						}
					}
				}
			}
		}

		for (int extra : new int[] { 0, 1, 5 }) {
			for (int l : new int[] { 1, 10 }) {
				for (int r : new int[] {(int) 1e8, (int) (1e8 - 10) }) {
					for (int m : new int[] { 5, 100, 10 }) {
						for (int maxLen : new int[] { 2 * (int) 1e5, (int) 1e8 }) {
							if (rnd.nextBoolean() || rnd.nextBoolean()) {
								continue;
							}
							t.genFull(m, (int) 1e8, extra, l, r, maxLen);
							t.chimneySway(-5, 5);
							t.printTest();
						}
					}
				}
			}
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

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