program mirage;
var
crush:array [1..2,1..4] of real;
sum:array [1..2] of real;
engine:array [1..3] of integer;
t:array [1..3] of extended;
team,i,j,n:longint;
s3,e,s1,s2,c,a:extended;
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);a:=1;
for i:=1 to n do begin
readln (c,team);
inc(team);
t[team]:=t[team]+c;
a:=a*c;
end;
t[3]:=t[1]+t[2];
t[1]:=t[3]-2*t[1];
t[2]:=t[3]-2*t[2];
t[3]:=t[3]-exp(ln(a)*(1/n))*10;
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+t[3]*s3;
close (input);
write (s1:0:2);
write (' ');
write (s2:0:2);
write (' ');
writeln (s3:0:2);
writeln (e:0:2);
close (output);
end.