#include <bits/stdc++.h>
using namespace std;

#define swap(i,j) { int tmp = i; i = j; j = tmp; }

int n;
vector< pair<int, int> > graph[100010];
vector<int> tree[100010];
vector<int> subtree[100010];

int par[100010] = {};
int num[100010] = {};
int deep[100010] = {};
int vid[100010];
int nid[100010];
int head[100010];
int team[100010];
int dist[100010];
int size[100010] = {};
int b = 0;

bool used[100010] = {};
int maketree(int i){
  used[i] = true;
  for(int x = 0;x < graph[i].size();x++){
    if(!used[graph[i][x].first]){
      par[graph[i][x].first] = i;
      dist[graph[i][x].first] = graph[i][x].second;
      tree[i].push_back(graph[i][x].first);
      maketree(graph[i][x].first);
    }
  }
}

int setnum(int i, int j, int k){
  dist[i] = j+dist[i];
  deep[i] = k;
  if(tree[i].size() == 0) return num[i] = 1;

  int ret = 1;
  for(int x = 0;x < tree[i].size();x++){
    ret += setnum(tree[i][x],dist[i],k+1);
  }

  return num[i] = ret;
}

void dis(int n){
  memset(team,-1,sizeof(team));
  priority_queue<pair<int, int> > que;
  for(int i = 0;i < n;i++){
    que.push(make_pair(num[i], i));
  }

  int gnum = 0;
  int next;
  int pos = 0;
  int i;
  while(!que.empty()){
    i = que.top().second; que.pop();
    if(team[i] != -1) continue;
    team[i] = gnum;
    size[gnum]++;
    subtree[gnum].push_back(i);
    nid[i] = 0;
    int nn = 1;
    head[i] = i;
    vid[i] = pos;
    pos++;
    next = i;
    while(tree[next].size() != 0){
      int maxi = 0;
      for(int j = 1;j < tree[next].size();j++){
        if(num[tree[next][maxi]] < num[tree[next][j]]){
          maxi = j;
        }
      }
      subtree[gnum].push_back(tree[next][maxi]);
      team[tree[next][maxi]] = gnum;
      head[tree[next][maxi]] = i;
      vid[tree[next][maxi]] = pos;
      nid[tree[next][maxi]] = nn;
      size[gnum]++;
      pos++;
      nn++;
      next = tree[next][maxi];
    }
    gnum++;
  }
  return;
}

void build(int n){
  maketree(0);
  setnum(0,0,0);
  dis(n);
  return;
}

int lca(int i, int j){
  while(1){
    if(vid[i] > vid[j]) swap(i, j);
    if(head[i] == head[j]) return i;
    j = par[head[j]];
  }
}

int getdist(int i, int j){
  return dist[i] + dist[j] - 2 * dist[lca(i, j)];
}

int getlen(int i, int j){
  return deep[i] + deep[j] - 2 * deep[lca(i, j)];
}

int treeSearch(int a, int m){
  if(size[team[a]] - (size[team[a]]-nid[a]-1) > m){
    return subtree[team[a]][nid[a]-m];
  }else{
    return treeSearch(par[head[a]],m-(size[team[a]]-(size[team[a]]-nid[a]-1)));
  }
}

int x, y, z;
int maxdist(int i){
  return max(getdist(x,i), max(getdist(y,i),getdist(z,i)));
}

int ordist(int i,int a){
  return max(getdist(x,i) * (x != a), max(getdist(y,i) * (y != a) ,getdist(z,i) * (z != a)));
}

int path(int u, int v, int d){
  if(d == 0) return 0;
  int r = lca(u, v);
  int x = getlen(u, r), y = getlen(r, v);
  if(d <= x) return treeSearch(u,d);
  return treeSearch(v,(x+y)-d);
}

int search(int u, int v, int ans){

  if(ordist(v, u) >= ans) return ans;

  int left = 0;
  int right = getlen(u, v);
  int dat, mid;

  while(left+1 < right){
    mid = (left + right) / 2;
    dat = path(u,v,mid);
    if(ordist(dat,u) < getdist(dat,u)){
      right = mid;
    }else{
      left = mid;
    }
  }

  return min(ans,min(maxdist(path(u,v,left)),maxdist(path(u,v,right))));
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int q;
  cin >> n >> q;

  int a, b, c;
  for(int i = 0;i < n-1;i++){
    cin >> a >> b >> c;
    a--; b--;
    graph[a].push_back(make_pair(b,c));
    graph[b].push_back(make_pair(a,c));
  }

  build(n);

  int mid;
  int ans;
  for(int i = 0;i < q;i++){
    cin >> x >> y >> z;
    x--; y--; z--;
    a = lca(x,y); b = lca(y,z); c = lca(z,x);
    mid = deep[a] > deep[b] ? (deep[a] > deep[c] ? a : c) : (deep[b] > deep[c] ? b : c);
    ans = min(maxdist(x), min(maxdist(y), min(maxdist(z), maxdist(mid))));

    ans = search(x,mid,ans);
    ans = search(y,mid,ans);
    ans = search(z,mid,ans);

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 25796