#include using namespace std; #define I int #define S(a) scanf("%d",&a); #define R for(I i=0;i<(N);i++) struct D{vector V;D(I n){V.assign(n,-1);}I r(I a){return(V[a]<0)?a:(V[a]=r(V[a]));}I u(I a,I b){a=r(a);b=r(b);return(a==b)?-1:(V[b]=a);}}; I N,A[100000],u,v,g; double P[100000],ans=0.0; double f(I i){return A[i]*A[i]/P[i];} I main(){ S(N)D G(N);R S(A[i]);R {S(u);A[i]-=u;}R {S(u);P[i]=1./u;ans+=f(i);}S(N) R{S(u)S(v)u=G.r(u-1);v=G.r(v-1);if(u!=v){g=G.u(u,v);ans-=f(u)+f(v);A[g]+=A[u+v-g];P[g]+=P[u+v-g];ans+=f(g);}printf("%.4f\n",ans);} return 0;}