#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; const int MAX=100010; const int MAX_LOG=17; vector> G[MAX]; int root; int parent[MAX_LOG][MAX]; int depth[MAX]; ll len[MAX]; void dfs(int v,int p,int d,ll l){ parent[0][v]=p; depth[v]=d; len[v]=l; for(auto x:G[v]){ if(x.first==p) continue; dfs(x.first,v,d+1,l+x.second); } } void init(int u){ dfs(root,-1,0,0); for(int k=0;k+1depth[v]) swap(u,v); for(int k=0;k=0;k--){ if(parent[k][u]!=parent[k][v]){ u=parent[k][u]; v=parent[k][v]; } } return parent[0][u]; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; rep(i,n-1){ int a,b; ll c; cin>>a>>b>>c; G[a].push_back({b,c}); G[b].push_back({a,c}); } root=0; init(n); int q; cin>>q; while(q--){ int x,y,z; cin>>x>>y>>z; cout<