import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 18446744073709551615 inf = 4294967295 md = 10**9+7 # md = 998244353 class UnionFind: def __init__(self, n, dd, ip): self.state = [-1]*n self.size_table = [1]*n self.dd = dd self.ip = ip # cntはグループ数 self.cnt = n def root(self, u): stack = [] while self.state[u] >= 0: stack.append(u) u = self.state[u] for v in stack: self.state[v] = u return u def same(self, u, v): return self.root(u) == self.root(v) def merge(self, u, v): u = self.root(u) v = self.root(v) if u == v: return False du = -self.state[u] dv = -self.state[v] if du < dv: u, v = v, u if du == dv: self.state[u] -= 1 self.state[v] = u self.cnt -= 1 self.size_table[u] += self.size_table[v] self.dd[u] += self.dd[v] self.ip[u] += self.ip[v] return True # グループの要素数 def size(self, u): return self.size_table[self.root(u)] def get_dp(self, u): u = self.root(u) return self.dd[u], self.ip[u] n = II() aa = LI() bb = LI() pp = LI() uf = UnionFind(n, [a-b for a, b in zip(aa, bb)], [1/p for p in pp]) s = sum(p*(a-b)**2 for a, b, p in zip(aa, bb, pp)) for _ in range(II()): x, y = LI1() if not uf.same(x, y): d, p = uf.get_dp(x) s -= d**2/p d, p = uf.get_dp(y) s -= d**2/p uf.merge(x, y) d, p = uf.get_dp(x) s += d**2/p print(s)