{$Q+,R+,I+,O-}

uses SysUtils,testlib;
                                                                                  
var x,n,i,y:integer;
    k:extended;
    a,b:array[1..100000] of double;
    gone:array[1..100000] of boolean;

begin
  n:=inf.readLongint;
  k:=inf.readReal;
  if k = -1.0 then exit;
  for i:=1 to n do begin
    a[i]:= inf.readReal;
    b[i]:= -inf.readReal;
  end;
  y:=0;
  fillchar (gone, sizeof (gone), 0);
  for i:=1 to n do begin
    x := ouf.readLongint;
    if ((x<=0) or (x>n) or gone[x]) then 
      quit(_PE,'it is not a permutation');
    gone[x] := true;
    if (y>0) and ((a[x]-1)*b[y]<(a[y]-1)*b[x]-1e-8) then
      quit(_WA,'not the best result');
    y:=x;
  end;
  if (not ouf.seekeof) then 
    quit(_PE,'extra info');
  quit(_OK,'ok');
    
end.
