var f,th:string;
m,k,AC,RE,WA,i,j,ans,maxn:longint;
real:array[1..1000]of longint;
tt,tf:boolean;
function woqu(a:char):byte;
begin
case a of'#':exit(3);
'+','-':exit(1);
'*','/':exit(2);
end;
end;
function ff(a,b:longint):longint;
var i,t1,t2,v,k:longint;
z:string;
c:char;
begin
if b<a then exit(0);c:='#';v:=0;
for i:=b downto a do
begin
if f[i]=')' then inc(v);
if f[i]='(' then dec(v);
if (f[i] in ['*','+','-','/']) and(v=0) then
begin
if woqu(c)>woqu(f[i]) then
begin
c:=f[i];
k:=i;
end;
end;
end;
if c<>'#' then
begin
t1:=ff(a,k-1);
t2:=ff(k+1,b);
case c of
'+':exit(t1+t2);
'-':exit(t1-t2);
'*':exit(t1*t2);
'/':exit(t1 div t2);
end;
end;
if f[a]='(' then exit(ff(a+1,b-1));
z:=copy(f,a,b-a+1);
val(z,k);
exit(k);
end;
begin
//assign(output,'aa.txt');
//rewrite(output);
readln(maxn);
WRITELN('MAXN=',MAXN,';');
for i:=1 to maxn do begin
readln(f);
if f[1]='-' then f:='0'+f;
real[i]:=ff(1,length(f));
end;
for i:=1 to maxn do begin
readln(th); tt:=false;tf:=false;
while (th[j]=' ')and(j<=length(th)) do begin inc(j); tf:=true;end;
if tf then delete(th,1,j);
for j:=1 to length(th) do
if ((th[j]>'9')or(th[j]<'0'))and(th[1]<>'-') then
begin inc(re);
writeln('TESE#',i,' ','RE ','sore#',i,'=0;');
tt:=true; break;
end;
if tt then continue;
val(th,ans);
if ans<>real[i] then begin
inc(wa);
writeln('TESE#',i,' ','WA ','sore#',i,'=0;');
end
else
if ans=real[i] then begin
inc(ac);
writeln('TESE#',i,' ','AC ','sore#',i,'=',100 div maxn,';');
end;
end;
writeln('SORE=',ac/maxn*100:0:0,';');
writeln('AC*',ac,';RE*',RE,';WA*',WA,';');
//close(output);
end.