{ VERIFICATION PROGRAM for PAIRS problem for NEERC'2001 }
{ (C) Roman Elizarov }
{$APPTYPE CONSOLE}
program PAIRS_CHECK;
uses
  sysutils, testlib in '..\testlib.pas';

var
  ians, iouf, i: integer;
  sans, souf: string;
  wa: boolean;
  wm: string;

begin
  try 
    wa := false;

    iouf := ouf.readInteger;
    ians := ans.readInteger;
    if iouf <> ians then begin
      wa := true;
      wm := 'Wrong answer: ' + IntToStr(iouf) + ' <> ' + IntToStr(ians);
    end;
    if Trim(ouf.readString()) <> '' then 
      Quit(_PE, 'Extra characters on line');
    if Trim(ans.readString()) <> '' then 
      Quit(_FAIL, 'Extra characters on line');
    for i := 1 to iouf do begin
      souf := ouf.readString;
      if not wa then begin
        sans := ans.readString;
        if souf <> sans then begin
          wa := true;
          wm := 'Wrong answer: ' + souf + ' <> ' + sans;
        end;
      end;
    end;
    if not ouf.seekeof then
      Quit(_PE, 'Extra data in file');
    if wa then 
      Quit(_WA, wm);
    Quit(_OK, 'Ok');
  except on e: Exception do 
    Quit(_FAIL, e.Message);
  end;
end.
