program gen_random;

{$APPTYPE CONSOLE}

uses SysUtils;

const
	MAX_LEN = 100000;

var
  i, len, t, l, r, c, k: integer;
  num, tmp : string;
begin
	i:=1;
	while (FileExists(IntToStr(i)+'.in')) do inc(i);
	rewrite(output,IntToStr(i)+'.in');
	
  randomize;
  
  t := 1;
  if paramcount>0 then len := strtoint(paramstr(1)) else len := random(MAX_LEN)+1;
  if paramcount>1 then t := strtoint(paramstr(2));
  if (t = 3) then num := paramstr(3);
  
  if t=1 then begin
  	// random
  	num := chr(random(9)+1+ord('0'));
  	for i:= 2 to len do num := num + chr(random(10)+ord('0'));
  end else if t=2 then begin
  	// random with answer
  	
  	if len > 1 then begin
  	
  		l := random(9)+1;
  		r := random(10);
  		
  		while l+r>=9 do begin
  			l := random(9)+1;
  			r := random(10);
  		end;
  		
  		tmp := chr(l+ord('0'));
  		for i:=2 to len-1 do tmp := tmp + chr(random(10)+ord('0'));
  		tmp := tmp+chr(r+ord('0'));
  		for i:=1 to len do num := num+'0';
  		c := 0;
  		for i:=len downto 1 do begin
  		  k := ord(tmp[i])+ord(tmp[len-i+1])-2*ord('0')+c;
  		  num[i] := chr((k mod 10) + ord('0'));
  		  c := k div 10;
  		end;
  		
  	end else begin
  		l := (random(4)+1)*2;
  		num := chr(l+ord('0'));
  	end;
  	
  end else if t=3 then begin
  	// given
  end;
  
  writeln(num);
  
  sleep(20);
end.