uses
	sysutils;
var
	i, n, a, b: longint;
	p, q, s: array [1..100] of longint;
	ca, cb, cpqs: longint;
begin
	n := strtoint(paramstr(1));
	ca := strtoint(paramstr(2));
	cb := strtoint(paramstr(3));
	cpqs := strtoint(paramstr(4));
	randseed := strtoint(paramstr(5));

	a := random(ca) + 1;
	b := random(cb) + 1;

	for i := 1 to n do begin
		p[i] := random(cpqs) + 1;
		q[i] := random(cpqs) + 1;
		s[i] := random(cpqs) + 1;
	end;

	writeln(n, ' ', a, ' ', b);
	for i := 1 to n do begin
		writeln(p[i], ' ', q[i], ' ', s[i]);
	end;
end.