{ NEERC'98 Problem "Rating"
  Checking program by Roman Elizarov
  19.11.98
}
{$A+,B-,D+,E+,F-,G+,I+,L+,N+,O-,P-,Q+,R+,S+,T-,V+,X+,Y+}
program RATING_CHECK;
uses
  testlib;

const
  maxid = 100;

type
  idset = set of 1..maxid;
  result = record
             c: integer;
             l: array[1..maxid] of idset;
           end;

procedure ReadRes ( var s: InStream; var r: result );
var
  many: boolean;
  this: longint;
  all: idset;
begin
  many:= false;
  r.c:= 1;
  r.l[1]:= [];
  all:= [];
  while not s.seekeof do begin
    this:= s.readlongint;
    if (this < 1) or (this > maxid) then
      s.QUIT ( _PE, 'Invalid id');

    if this in all then
      s.QUIT ( _PE, 'Repeated id');
    include ( r.l[r.c], this );
    include ( all, this );

    if s.seekeoln and not s.seekeof then begin
      if r.c >= maxid then
        many:= true
      else begin
        inc ( r.c );
        r.l[r.c]:= [];
      end;
    end;
  end;
  if many then
    s.QUIT ( _WA, 'Too many lines in file' );
end;

var
  r_ans, r_ouf: result;
  i: integer;

begin
  ReadRes ( ans, r_ans );
  ReadRes ( ouf, r_ouf );
  if r_ouf.c <> r_ans.c then
    QUIT ( _WA, 'Wrong line count');
  for i:= 1 to r_ans.c do
    if r_ouf.l[i] <> r_ans.l[i] then
      QUIT ( _WA, 'Wrong line');
  QUIT ( _OK, 'Ok' );
end.
