{
Written by Fyodor Menshikov 18.02.2005
}
   procedure ac;
   begin
      writeln('ac');
      halt;
   end;

   procedure wa;
   begin
      writeln('wa');
      halt(1);
   end;

   procedure pe;
   begin
      writeln('pe');
      halt(2);
   end;

var
   fin,fout,fchk:text;
   us,os,js:string;
begin
   assign(fin,ParamStr(1));
   reset(fin);
   assign(fout,ParamStr(2));
   reset(fout);
   while not eof(fout) do begin
      readln(fout,us);
      while true do begin
         if eof(fin) then
            pe;{no such word in dictionary}
         readln(fin,os);
         if us=os then
            break;
      end;
   end;
   assign(fchk,ParamStr(3));
   reset(fchk);
   reset(fout);
   while true do begin
      if eof(fout) and eof(fchk) then
         ac;
      if eof(fout) or eof(fchk) then
         wa;
      readln(fout,us);
      readln(fchk,js);
      if us<>js then
         wa;
   end;
end.