#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

#define long long long // for codeforces

const long N = 100010;
const long INF = 123456789123456789;

struct edge {
  int to,w;
};

vector<edge> G[N];
long d[N];

class LCA {
public:
  int n, ln; // number of nodes and its log
  vector<vector<int>> parent;
  vector<int> depth;
  LCA(int _n, int root=-1) : n(_n), depth(_n){
    ln=0;
    while(n>=(1<<ln)) ln++;  // calc log n
    parent = vector<vector<int>>(ln, vector<int>(n));
    if(root!=-1) init(root);
  }
  void dfs(const int v, const int p, const int w){
    parent[0][v] = p;
    depth[v] = w;
    for(auto to : G[v]) if(to.to != p) dfs(to.to, v, w+1);
  }
  void init(const int root){
    dfs(root, -1, 0);
    for(int k=0; k+1<ln; k++){
      for(int v=0; v<n; v++){
        if(parent[k][v] < 0) parent[k+1][v] = -1;
        else parent[k+1][v] = parent[k][parent[k][v]];
      }
    }
  }
  int query(int u, int v) const {
    if(depth[u] > depth[v]) swap(u,v);
    for(int k=0; k<ln; k++){
      if((depth[v]-depth[u])>>k & 1) v = parent[k][v];
    }
    if(u==v) return u;
    for(int k=ln-1; k>=0; k--){
      if(parent[k][u] != parent[k][v]){
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
  long dist(const int s, const int t) const {
    int p = query(s,t);
    if(s != p && t != p) return d[s] + d[t] - 2*d[p];
    else return abs(d[s] - d[t]);
  }
};

void bfs(int v){
  for(auto e: G[v]) if(d[e.to] == INF) {
    d[e.to] = d[v] + e.w;
    bfs(e.to);
  }
}

int main(){
  int n,q;
  cin>>n>>q;

  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G[a].pb({b,c});
    G[b].pb({a,c});
  }

  const int root = 0;
  LCA lca(n, root);
  fill(d, d+n, INF);
  d[root] = 0;
  bfs(root);

  rep(_,q){
    int a,b,c;
    cin>>a>>b>>c;
    dbg(a,b,c);
    a--;b--;c--;

    long ab = lca.dist(a,b);
    long bc = lca.dist(b,c);
    long ca = lca.dist(c,a);

    int x,y;
    if(ab >= bc && ab >= ca) {x=a,y=b;}
    else if(bc >= ab && bc >= ca) {x=b,y=c;}
    else {x=a,y=c;}

    int ch;

    int l = lca.query(x,y);
    long dx = lca.dist(l,x);
    long dy = lca.dist(l,y);
    if(dx >= dy) ch = x;
    else ch = y;

    long ddd = lca.dist(x,y);

    // ch から l までダブリングして求める
    const auto calc = [&](const int m) {
      return max(lca.dist(a,m), max(lca.dist(b,m), lca.dist(c,m)));
    };
    int mid = ch;
    for(int k = lca.ln-1; k >= 0; k--){
      if(lca.parent[k][mid] != -1){
        int cand = lca.parent[k][mid];
        if(lca.depth[l] > lca.depth[cand]) continue;
        if(lca.dist(ch, cand)*2 <= ddd) mid = cand;
      }
    }

    long ans = calc(mid);
    if(lca.parent[0][mid] != -1) ans = min(ans, calc(lca.parent[0][mid]));

    cout << ans << "\n";
  }

  return 0;
}



Measured memory_bytes: 20684