#include using namespace std; constexpr int kN = int(2E5 + 10); int union_find[kN], a[kN], b[kN], p[kN], x[kN], y[kN]; long long int sum_a[kN], sum_b[kN]; double ans, sum_of_inverse_p[kN]; double Cal(int n) { double x = fabs(sum_a[n] - sum_b[n]); return x * x / sum_of_inverse_p[n]; } int Find(int n) {return n == union_find[n] ? n : union_find[n] = Find(union_find[n]);} void Merge(int l, int r) { l = Find(l), r = Find(r); if (l != r) { ans -= Cal(l); ans -= Cal(r); union_find[r] = l; sum_a[l] += sum_a[r]; sum_b[l] += sum_b[r]; sum_of_inverse_p[l] += sum_of_inverse_p[r]; ans += Cal(l); } return ; } int main() { int n, q; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= n; i++) scanf("%d", &b[i]); for (int i = 1; i <= n; i++) scanf("%d", &p[i]); scanf("%d", &q); for (int i = 1; i <= q; i++) scanf("%d%d", &x[i], &y[i]); for (int i = 1; i <= n; i++) sum_a[i] = a[i]; for (int i = 1; i <= n; i++) sum_b[i] = b[i]; for (int i = 1; i <= n; i++) sum_of_inverse_p[i] = 1.0 / p[i]; for (int i = 1; i <= n; i++) union_find[i] = i; for (int i = 1; i <= n; i++) ans += Cal(i); for (int i = 1; i <= q; i++) { Merge(x[i], y[i]); printf("%.20lf\n", ans); } }