{$q+,r+,o-}
{$APPTYPE CONSOLE}
uses
    tools;
var
    root: longint;
    funcs: longint;
    vars: longint;
    length: longint;
    ch: char;
    i: longint;
    u: array ['A'..'Z'] of boolean;
begin
    read(randseed);
    read(funcs);
    read(vars);
    read(length);

    writeln(funcs);
    for i := 1 to funcs do begin
    	repeat	
    		ch := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[random(26) + 1];
		until not u[ch];
		u[ch] := true;
    	write(ch, ':=');
    	ops := 0;
    	root := generate(length, vars);
    	outputRandom(root);
    end;
end.
