{$APPTYPE CONSOLE}

uses SysUtils;
var
  f: TextFile;
  i, j, p, N: Integer;
begin
  RandSeed := 37;
  N := StrToInt(ParamStr(1)); 
  p := StrToInt(ParamStr(2)); 
  if ParamStr(3) <> '' then RandSeed := StrToInt(ParamStr(3));
  AssignFile(f, 'input.txt'); Rewrite(f);
  Writeln(f, N);
  for i := 1 to N do begin
    for j := 1 to N do
      if (i = 2) and (j = 2) then Write(f, '*')
      else if Random(100) < p then Write(f, '#')
      else Write(f, '.');
    Writeln(f);
  end;
  CloseFile(f);
end.
