{$R+}
uses
	math;
var
	m, n, s, t, maxc, maxg, e, i, j, x, y: longint;
	tmp: longint;
	a, b, c: array [1..100000] of longint;
	d: array [1..20000] of longint;
	pv: array [1..20000] of longint;
	pe: array [1..100000] of longint;
	pl: longint;
	reqd: longint;
begin
	randseed := 912734073;

	n := 20000;
	m := 100000;
	s := 1;
	t := n;
	maxc := 100000;
    maxg := 100;
	pl := 99;
	reqd := 200;

	d[1] := 0;
	e := 0;
	for i := 2 to n do begin
		d[i] := d[i - 1] + random(maxg) + 1;
		inc(e);
		a[e] := i - 1;
		b[e] := i;
		c[e] := d[i] - d[i - 1];
	end;

	while e < m do begin
		repeat
			x := random(n) + 1;
			y := x + random(reqd) + 1;
		until y <= n;
		inc(e);
		a[e] := x;
		b[e] := y;
		if (random(100) < pl) then begin
			c[e] := min(maxc, d[y] - d[x] + random(max(1, maxc - (d[y] - d[x]) + 1)));
		end else begin
			c[e] := min(maxc, d[y] - d[x]);
		end;
		if (c[e] < 0) then
			asm int 3 end;
	end;

	for i := 1 to m do begin
		j := random(i) + 1;
		pe[i] := pe[j];
		pe[j] := i;
	end;

	for i := 1 to n do begin
		j := random(i) + 1;
		pv[i] := pv[j];
		pv[j] := i;
	end;

	for i := 1 to n do begin
		if pv[i] = 1 then begin
			tmp := pv[i]; pv[i] := pv[s]; pv[s] := tmp;
			break;
		end;
	end;
	for i := 1 to n do begin
		if pv[i] = n then begin
			tmp := pv[i]; pv[i] := pv[t]; pv[t] := tmp;
			break;
		end;
	end;

	writeln(n, ' ', m);
	for i := 1 to m do begin
		if random(2) = 0 then
			writeln(pv[a[pe[i]]], ' ', pv[b[pe[i]]], ' ', c[pe[i]])
		else                                       
			writeln(pv[b[pe[i]]], ' ', pv[a[pe[i]]], ' ', c[pe[i]]);
	end;
end.