program simulator;
type
fxz1=array[0..10000] of longint;
fxz2=array[0..10000] of real;
var
f1,f2:text;
vv,i,ls,n,cc:longint;
s:char;
v:fxz1;
c:fxz2;
begin assign(f1,'simulator.in');
assign(f2,'simulator.out');
reset(f1);rewrite(f2);
readln(f1,v[0],c[0]);
readln(f1,n);
ls:=0;
for i:=1 to n do begin read(f1,s);
if s='z' then begin if ls>0 then dec(ls);end
else begin inc(ls);
read(f1,s,vv,cc);
v[ls]:=v[ls-1]+vv;
c[ls]:=(vv*cc+v[ls-1]*c[ls-1])/v[ls];
end;
readln(f1);
writeln(f2,v[ls],' ',c[ls]:0:5);
end;
close(f1);close(f2);
end.