#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 100010
#define D 18
ll n,q,p[N],len[N],rui[N],dep[N];
namespace lca{
  ll t[N][D];
  void init(){
      for(int i=1;i<=n;i++)t[i][0]=p[i];
      for(int d=1;d<D;d++){
	  for(int i=1;i<=n;i++){
	      t[i][d]=t[t[i][d-1]][d-1];
	  }
      }
  }
  ll ad(ll a,ll k){
      for(ll d=0;k!=0;d++){
	  if(k&1)a=t[a][d];
	  k>>=1;
      }
      return a;
  }
  ll qry(ll a,ll b){
      if(dep[a]<dep[b])swap(a,b);
      a=ad(a,dep[a]-dep[b]);
      if(a==b)return a;
      for(ll d=D-1;d>=0;d--){
	  if(t[a][d]!=t[b][d]){
	      a=t[a][d],b=t[b][d];
	  }
      }
      return p[a];
  }
  ll dist(ll a,ll b){
      ll c=qry(a,b);
      return rui[a]+rui[b]-2*rui[c];
  }
};


struct edge{
  ll to,cost;  
};
edge edges(ll to,ll cost){
    edge gen;gen.to=to,gen.cost=cost;
    return gen;
}
vector<edge> g[N];
void dfs(ll x,ll from,ll sum,ll d){
    rui[x]=sum; dep[x]=d;
    for(auto y:g[x])if(y.to!=from){
	p[y.to]=x,len[y.to]=y.cost;
	dfs(y.to,x,sum+y.cost,d+1);
    }
}

ll ldi(ll mid,ll a,ll b,ll c,ll lk,ll rk,ll m){//cout<<"ldi"<<mid<<endl;
    ll ldis;
    if(mid<=lk)ldis=lca::dist(a,lca::ad(a,mid));
    else ldis=lca::dist(a,c)+lca::dist(c,lca::ad(b,m-mid));
    return ldis;
}
ll rdi(ll mid,ll a,ll b,ll c,ll lk,ll rk,ll m){//cout<<"rdi"<<mid<<endl;
    ll rdis;
    if(mid>=lk)rdis=lca::dist(b,lca::ad(b,m-mid));
    else rdis=lca::dist(b,c)+lca::dist(c,lca::ad(a,mid));
    return rdis;
}
int main(){
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
	ll a,b,c;cin>>a>>b>>c;
	g[a].push_back(edges(b,c));
	g[b].push_back(edges(a,c));
    }
    dfs(1,0,0,0); p[1]=1;
    lca::init();
    while(q--){
	ll a,b,c;cin>>a>>b>>c;
	ll ab=lca::dist(a,b);
	ll ac=lca::dist(a,c);
	ll bc=lca::dist(b,c);
	if(ab>=ac&&ab>=bc){}
	else if(ac>=ab&&ac>=bc){swap(b,c);}
	else if(bc>=ab&&bc>=ac){swap(a,c);}
	c=lca::qry(a,b);//cout<<"$$$$$"<<a<<" "<<b<<" "<<c<<endl;
	ll lk=dep[a]-dep[c],rk=dep[b]-dep[c],m=lk+rk;
	ll l=0,r=m,mid;
	while(l<r-1){
	    mid=(l+r)/2;
	    ll ldis=ldi(mid,a,b,c,lk,rk,m);
	    ll rdis=rdi(mid,a,b,c,lk,rk,m);
	    if(ldis<rdis)l=mid;
	    else r=mid;
	}
	ll ldis,rdis;
	ldis=ldi(l,a,b,c,lk,rk,m);
	rdis=rdi(l,a,b,c,lk,rk,m);
	ll vl=max(ldis,rdis);
	ldis=ldi(r,a,b,c,lk,rk,m);
	rdis=rdi(r,a,b,c,lk,rk,m);
	ll vr=max(ldis,rdis);
	cout<<min(vl,vr)<<endl;
    }
    return 0;
}

