program mirage;
var
crush:array [1..2,1..4] of double;
sum:array [1..2] of double;
engine:array [1..3] of longint;
t:array [1..3] of double;
data:array [1..100000] of double;
team,i,j,n:longint;
ta,s3,e,s1,s2,c:double;
begin
t[1]:=0;t[2]:=0;
assign (input,'mirage.in');
reset (input);
for i:=1 to 2 do begin
for j:=1 to 4 do read (crush[i,j]);
readln;
end;
readln (engine[1],engine[2]);
engine[3]:=engine[1]+engine[2];
readln (n);
for i:=1 to n do begin
readln (c,team);
inc(team);
data[i]:=c;
t[team]:=t[team]+c;
end;
t[3]:=t[1]+t[2];
t[1]:=t[3]-2*t[1];
t[2]:=t[3]-2*t[2];
ta:=1;
for i:=1 to n do ta:=ta*(exp(ln(data[i])/n));
ta:=t[3]-ta*n;
assign (output,'mirage.out');
rewrite (output);
sum[1]:=1;sum[2]:=1;
for i:=1 to 2 do for j:=1 to 4 do sum[i]:=sum[i]*(1-crush[i,j]);
s1:=sum[1]*sum[2]*(engine[1]/engine[3])+(1-sum[2])*sum[1];
s2:=sum[1]*sum[2]*(engine[2]/engine[3])+(1-sum[1])*sum[2];
s3:=(1-sum[1])*(1-sum[2]);
e:=t[1]*s1+t[2]*s2+ta*s3;
close (input);
write (s1:0:2);
write (' ');
write (s2:0:2);
write (' ');
writeln (s3:0:2);
writeln (e:0:2);
close (output);
end.