program xmz;
var
n,i,a:longint;
v:array[0..10000]of longint;
c:array[0..10000]of real;
ch:char;
f1,f2:text;
begin
assign(f1,'simulator.in');assign(f2,'simulator.out');
reset(f1);rewrite(f2);
read(f1,v[0],c[0]);
readln(f1,n);
for a:=1 to n do
begin
read(f1,ch);
if ch='P' then
begin
inc(i);
readln(f1,v[i],c[i]);
c[i]:=(v[i-1]*c[i-1]+v[i]*c[i])/(v[i-1]+v[i]);
v[i]:=v[i]+v[i-1];
end;
if ch='Z' then begin readln(f1);dec(i);if i<0 then i:=0;end;
writeln(f2,v[i],' ',c[i]:0:5);
end;
close(f1);close(f2);
end.