   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;
  INFINITY = 102;

var
  n: integer;
  a: array[1..NMAX,1..NMAX] of integer;
  visited: array[1..NMAX] of boolean;
  i,j,k,u,v: LongInt;
  fans: Text;
  sans: String;
  
  ans: array[1..NMAX+1] of longint;

begin

  assign(input, paramstr(1));
  reset(input);
  readln(n);
  for i:=1 to n do for j:=1 to n do a[i,j]:=INFINITY;

  for i:=1 to n-1 do begin
    readln(u,v); a[u,v]:=1; a[v,u]:=1;
  end;

  {находим кратчайшие пути алгоритмом Флойда}
  for k:=1 to n do
    for i:=1 to n do
      for j:=1 to n do
        if a[i,k]+a[k,j]<a[i,j] then a[i,j]:=a[i,k]+a[k,j];

  assign(fans,ParamStr(2)); reset(fans);
  readln(fans,sans);
  if (sans<>'YES')and(sans<>'NO') then pe;
  if (n=1)and(sans='YES') then wa;
  if sans='NO' then wa;

  for i:=1 to n+1 do read(fans,ans[i]);
  if not seekeoln(fans) then pe;
  fillchar(visited,sizeof(visited),false);
  if (ans[1]<1)or(ans[1]>n) then wa;
  visited[ans[1]]:=true;
  for i:=2 to n do 
  begin
    if (ans[i]<1)or(ans[i]>n) then wa;
    if visited[ans[i]] then wa;
    visited[ans[i]]:=true;
    if a[ans[i-1],ans[i]]>3 then wa;
  end;
  if ans[n+1]<>ans[1] then wa;
  if a[ans[n+1],ans[1]]>3 then wa;
  ac;
end.
