{$R+}
uses
	sysutils;

var
	n: longint;
	minc, maxc: int64;
	i: longint;
	x, y: array [0..100000] of int64;

	head: array [0..262143] of longint;
	next, v1, v2: array [1..200000] of longint;
	e: longint;

	cur, prev: longint;
	skew, wasskew: boolean;

function hash(u, v: longint): longint;
begin
	hash := ((int64(u) * 31 + v) mod 262144 + 262144) mod 262144;
end;

procedure add(u, v: longint);
var
	h: longint;
begin
	h := hash(u, v);
	inc(e);
	next[e] := head[h];
	v1[e] := u;
	v2[e] := v;
	head[h] := e;
end;

var
    _h: longint;

function exists(u, v: longint): boolean;
var
	j, h: longint;
begin
	exists := true;

	h := hash(u, v);
	j := head[h];
	while (j <> 0) do begin
		if (v1[j] = u) and (v2[j] = v) then begin
			exit;
		end;

		j := next[j];
	end;

	exists := false;
end;

function ok(x1, y1, x2, y2: longint): boolean;
begin
	ok := 
		(x1 = x2) or
		(y1 = y2) or
		(x1 + y1 = x2 + y2) or
		(x1 - y1 = x2 - y2);
end;

begin
	n := strtoint(paramstr(1));
	minc := strtoint(paramstr(2));
	maxc := strtoint(paramstr(3));
	randseed := strtoint(paramstr(4));

	e := 0;

	add(0, 0);
	x[0] := 0;
	y[0] := 0;
	prev := -1;
	skew := false;
	wasskew := false;
	for i := 1 to n do begin
		repeat
    		repeat
    			cur := random(4);
    		until prev <> cur;
			case cur of 
				0: begin
					x[i] := x[i - 1];
					y[i] := minc + random(maxc - minc + 1);
				end;
				1: begin
					x[i] := minc + random(maxc - minc + 1);
					y[i] := y[i - 1];
				end;
				2: begin
					repeat
    					x[i] := minc + random(maxc - minc + 1);
    					y[i] := x[i - 1] + y[i - 1] - x[i];
    				until (minc <= y[i]) and (y[i] <= maxc);
				end;
				3: begin
					repeat
    					x[i] := minc + random(maxc - minc + 1);
    					y[i] := y[i - 1] - x[i - 1] + x[i];
    				until (minc <= y[i]) and (y[i] <= maxc);
				end;
			end;
			if not wasskew and (skew or ((i > 2 * n div 3) and (random(n div 3) = 0))) then begin
				writeln(erroutput, 'SKEW at ', i);
				skew := true;
  				x[i] := minc + random(maxc - minc + 1);
  				y[i] := minc + random(maxc - minc + 1);
			end;
		until (skew or ok(x[i], y[i], x[i - 1], y[i - 1])) and not exists(x[i], y[i]);
   		prev := cur;
		add(x[i], y[i]);
		if (skew) then
			wasskew := true;
		skew := false;
	end;

	writeln(n);
	for i := 1 to n do begin
		writeln(x[i], ' ', y[i]);
	end;
end.