#include <bits/stdc++.h>
using namespace std;
int read() {
  char c = getchar();
  int d = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; d = d * 10 + c - 48, c = getchar())
    ;
  return d * f;
}
char Read() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  return c;
}
const int N = 200001;
int n, q;
int cnt, head[N];
struct edge {
  int to, next;
} e[N * 2];
void addedge(int x, int y) {
  e[++cnt] = (edge){y, head[x]};
  head[x] = cnt;
}
void Addedge(int x, int y) {
  addedge(x, y);
  addedge(y, x);
}
int p[N], pp[N];
int fa[N];
void dfs(int f, int x) {
  for (int i = head[x], y = e[i].to; y; i = e[i].next, y = e[i].to)
    if (y != f) fa[y] = x, dfs(x, y);
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) p[i] = read() * 100, p[i] += read();
  for (int i = 2; i <= n; ++i) Addedge(read() + 1, read() + 1);
  dfs(0, 1);
  p[0] = 100;
  fa[1] = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += p[fa[i]] * (100 - p[i]);
  for (int i = 1; i <= n; ++i) pp[fa[i]] += 100 - p[i];
  q = read();
  for (int i = 1; i <= q; ++i) {
    int x = read() + 1;
    int P = read() * 100;
    P += read();
    ans += pp[x] * (P - p[x]);
    ans += (p[x] - P) * p[fa[x]];
    pp[fa[x]] += P - p[x];
    p[x] = P;
    printf("%.4lf\n", 1.0 * ans / 10000);
  }
}
