{$APPTYPE CONSOLE}

uses SysUtils, Math;
var
  f: TextFile;
  i, N, C: Integer;
begin
  RandSeed := 4;
  C := StrToInt(ParamStr(2)); 
  N := StrToInt(ParamStr(3)); 
  AssignFile(f, 'input.txt'); Rewrite(f);
  Writeln(f, C, ' ', N);
  for i := 1 to N do begin
    case ParamStr(1)[1] of
    'a': Writeln(f, Random(C) + 1, ' ', Random(20) + 1, ' ', Random(350) + 1, ' ', 1 - Sign(Random(10)));
    'b': Writeln(f, Random(C) + 1, ' ', Random(20) + 1, ' ', Random(35000) + 1, ' ', 1 - Sign(Random(10)));
    'c': Writeln(f, Random(C) + 1, ' ', Random(20) + 1, ' ', Random(35000) + 1, ' ', 0);
    'd': Writeln(f, Random(C) + 1, ' ', Random(6) + 1, ' ', Random(35000) + 1, ' ', 1 - Sign(Random(20)));
    end;
  end;
  CloseFile(f);
end.
