#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 1e5 + 10;
int n, q;
long double par[N][3];
vector<int> adj[N];
bool mark[N];
long double d, res, f[N], size[N];
struct edge {
  int a, b;
  long double l;
} e[N];
inline pair<long double, int> get(int i, int u) {
  if (u == e[i].a) return make_pair(e[i].l, e[i].b);
  return make_pair(e[i].l, e[i].a);
}
inline long double g(long double x) {
  x = x / (n - 0);
  x = x / (n - 1);
  x = x / (n - 2);
  x = x * 6;
  return x;
}
void DFS(int u) {
  size[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = get(adj[u][i], u).second;
    long double l = get(adj[u][i], u).first;
    if (v == par[u][1]) continue;
    par[v][0] = adj[u][i], par[v][1] = u, par[v][2] = l;
    DFS(v);
    size[u] += size[v];
  }
  if (u == 1) return;
  int i = par[u][0];
  long double l = par[u][2];
  f[i] = 1;
  f[i] = f[i] * g(size[u]);
  f[i] = f[i] * (n - size[u]);
  f[i] = f[i] * (n - 2);
  res += f[i] * l;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> e[i].a >> e[i].b >> e[i].l;
    adj[e[i].a].push_back(i);
    adj[e[i].b].push_back(i);
  }
  DFS(1);
  cin >> q;
  for (; q; q--) {
    int r;
    long double l;
    cin >> r >> l;
    res -= f[r] * (e[r].l - l);
    e[r].l = l;
    cout << fixed << setprecision(10) << res << endl;
  }
  return 0;
}
