{$APPTYPE CONSOLE}

{
	Checker for task "Pyramid"
}

uses
  TestLib;

const
  CSet = ['x', 'u', 'w', 'v', 'X', 'U', 'W', 'V', '*'];

var
  JAns, PAns: String;
  JCnt: LongInt;
  i: LongInt;

begin
  JCnt:= ouf.ReadLongInt;
  If JCnt > 0 then begin
    PAns:= ans.ReadWord(blanks, blanks);
    For i:= 1 to Length(PAns) do
      If not (PAns[i] in CSet)
        then Quit(_PE, 'Bad symbols in output');
    For i:= 1 to JCnt do begin
      JAns:= ouf.ReadWord(blanks, blanks);
      If JAns = PAns
        then Quit(_OK, 'Ok!');
    end;
  end else begin
    If ans.SeekEof
      then Quit(_OK, 'Ok!');
    PAns:= ans.ReadWord(blanks, blanks);
    For i:= 1 to Length(PAns) do
      If not (PAns[i] in CSet)
        then Quit(_PE, 'Bad symbols in output');
    Quit(_WA, 'Empty string expected');
  end;
  Quit(_WA, 'No match found');
end.