#include #include #define S second #define F first using namespace std; typedef long long ll; typedef pairP; ll n,m,a,b,c,dist[100000],parent[100000],depth[100000]; vector

v[100000]; void f(ll n,ll m,ll k){ //cout<depth[m])n=parent[n]; while(depth[m]>depth[n])m=parent[m]; while(n!=m){ n=parent[n]; m=parent[m]; } return n; } ll func(ll a,ll b){ return dist[a]+dist[b]-dist[LCA(a,b)]*2; } int main(void){ cin>>n; for(int i=0;i>a>>b>>c; v[a].push_back({b,c}); } f(0,0,0); cin>>m; for(int i=0;i>a>>b>>c; cout<<(func(a,b)+func(b,c)+func(c,a))/2<