// Exported by Exporter.exe // Included from A.cpp // Compile flags -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -fmax-errors=2 #include using namespace std; #define PB push_back #define F first #define S second #define MP make_pair #define MTP make_tuple typedef long long int ll; constexpr int kN = int(2E5 + 10); // constexpr int kMod = 998244353; // constexpr int kInf = 0x3f3f3f3f // constexpr ll kInf = 0x3f3f3f3f3f3f3f3f; template T ABS(T n) {return n >= 0 ? n : -n;} // Included from C:\Users\ianli\Desktop\CP\template\Various\Fast_IO.cpp static inline char Get_Raw_Char() { static char buf[1 << 16], *p = buf, *end = buf; if (p == end) { if ((end = buf + fread(buf, 1, 1 << 16, stdin)) == buf) return '\0'; p = buf; } return *p++; } static inline int Get_Digit() { char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); return int(c - '0'); } static inline int Get_PInt() { char c = Get_Raw_Char(); int ret; while (!isdigit(c)) c = Get_Raw_Char(); ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); return ret; } static inline int Get_Int() { char c = Get_Raw_Char(); bool neg = false; int ret; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); if (neg) return -ret; return ret; } static inline long long int Get_ll() { char c = Get_Raw_Char(); bool neg = false; long long int ret; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); if (neg) return -ret; return ret; } static inline long long int Get_Pll() { char c = Get_Raw_Char(); long long int ret; while (!isdigit(c)) c = Get_Raw_Char(); ret = int(c - '0'); while (isdigit(c = Get_Raw_Char())) ret = ret * 10 + int(c - '0'); return ret; } template static inline void Read_P(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); return ; } template static inline void Read(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); bool neg = false; while (!isdigit(c)) { if (c == '-') neg = true; c = Get_Raw_Char(); } n = int(c - '0'); while (isdigit(c = Get_Raw_Char())) n = n * 10 + int(c - '0'); if (neg) n = -n; return ; } template static inline void Read_Digit(T &n) { static_assert(is_integral::value); char c = Get_Raw_Char(); while (!isdigit(c)) c = Get_Raw_Char(); n = int(c - '0'); return ; } template static inline void Read(T &n, Targs&... Fargs) { Read(n); return Read(Fargs...); } template static inline void Read_Digit(T &n, Targs&... Fargs) { Read_Digit(n); return Read_Digit(Fargs...); } template static inline void Read_P(T &n, Targs&... Fargs) { Read_P(n); return Read_P(Fargs...); } // End of C:\Users\ianli\Desktop\CP\template\Various\Fast_IO.cpp int f[kN], a[kN], b[kN], p[kN], x[kN], y[kN]; ll sa[kN], sb[kN]; double ans, srp[kN]; double Cal(int n) { double sd = ABS(sa[n] - sb[n]); return sd * sd / srp[n]; } int Find(int n) {return n == f[n] ? n : f[n] = Find(f[n]);} void Merge(int l, int r) { l = Find(l), r = Find(r); if (l != r) { ans -= Cal(l); ans -= Cal(r); f[r] = l; sa[l] += sa[r]; sb[l] += sb[r]; srp[l] += srp[r]; ans += Cal(l); } } int main() { //ios::sync_with_stdio(false); //cin.tie(0); //freopen("file_name", "r", stdin); //freopen("file_name", "w", stdout); //fstream input, output; //input.open("file_name", ios::in); //output.open("file_name", ios::out); 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++) sa[i] = a[i]; for (int i = 1; i <= n; i++) sb[i] = b[i]; for (int i = 1; i <= n; i++) srp[i] = 1.0 / p[i]; for (int i = 1; i <= n; i++) f[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); } //input.close(); //output.close(); } // End of A.cpp