   procedure ac;
   begin
      writeln('ac');
      halt;
   end;

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

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

const
  NMAX=100;
  MMAX=100;  

var
  n,m,k: Integer;
  a: array[1..NMAX,1..MMAX] of Byte;

  aa: array[1..NMAX] of Byte;
  bb: array[1..MMAX] of Byte;  

  fin,fout,fans: Text;
  rightCount,userCount: Integer;
  i,j,ai,bi,v: Integer;
  c: char;


begin
   assign(fin,ParamStr(1));
   reset(fin);
   assign(fout,ParamStr(2));
   reset(fout);
   assign(fans,ParamStr(3));
   reset(fans);

   readln(fout,userCount);
   readln(fans,rightCount);
   if userCount<>rightCount then wa;
   close(fans);

   readln(fin,n,m,k);  
   fillchar(a,sizeof(a),0);
   for i:=1 to k do
   begin
     readln(fin,ai,bi);
     a[ai,bi]:=1;
   end;
   
   fillchar(aa,sizeof(aa),0);
   fillchar(bb,sizeof(bb),0);
   for i:=1 to userCount do 
   begin
     read(fout,c);
     if (c<>'A') and (c<>'B') then pe;
     if c='A' then
     begin
       readln(fout,v);
       if v>n then wa;
       if v<1 then pe;
       if aa[v]=1 then wa;
       aa[v]:=1;
     end else
     begin
       readln(fout,v);
       if v>m then wa;
       if v<1 then pe;
       if bb[v]=1 then wa;
       bb[v]:=1;
     end;
   end;


   for i:=1 to n do
     if aa[i]=0 then
       for j:=1 to m do
        if bb[j]=0 then
          if a[i,j]=1 then wa;
    
    ac;

end.
