Program simulator;
Type
abc=record
m:int64;
c:real;
end;
sc=array [0..10000] of abc;
Var
i,j:longint;
n:longint;
s:sc;
p,tm:longint;
k:char;
tc,m:real;
Begin
assign(input,'simulator.in');
assign(output,'simulator.out');
reset(input);
rewrite(output);
readln(s[0].m,s[0].c);
readln(n);
p:=0;
s[0].c:=s[0].c/100;
for i:=1 to n do begin
read(k);
if k='P' then begin
p:=p+1;
read(k);
readln(tm,tc);
m:=s[i-1].m*s[i-1].c;
m:=m+tm*(tc/100);
s[i].m:=s[i-1].m+tm;
s[i].c:=m/s[i].m;
end;
if k='Z' then begin
p:=p-2;
if p<=0 then begin
s[i].m:=s[0].m;
s[i].c:=s[0].c;
end
else begin
s[i].m:=s[p].m;
s[i].c:=s[p].c;
end;
readln;
end;
writeln(s[i].m,' ',(s[i].c*100):0:5);
end;
close(input);
close(output);
End.