//Code Author:-code_kika //
//Institution:-IIT(BHU) //
#include<bits/stdc++.h>
using namespace std;
//io
#define sf(x) scanf("%d",&x);
#define sf2(x,y) scanf("%d %d",&x,&y);
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d",x,y);
#define pf3(x,y,z) printf("%d %d %d",x,y,z);
#define sfl(x) scanf("%lld",&x);
#define sfl2(x,y) scanf("%lld %lld",&x,&y);
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);
#define pfl(x) printf("%lld",x);
#define pfl2(x,y) printf("%lld %lld",x,y);
#define pfl3(x,y,z) printf("%lld %lld %lld",x,y,z);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//basic
#define pb push_back
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007LL
//typedefs
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vll vector<ll>
#define vi vector<int>
//functions
#define all(c) c.begin(),c.end()
#define fill(c,val) memset(c,val,sizeof(c))
//debug
#ifdef TRACE
#define trace(x) cerr << #x << ": " << x << endl;
#define trace1(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace(x)
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define N 100005
int l[N],vis[N],pa[N],dp[N][18];
vi v[N];
void dfs(int node,int lvl){
vis[node]=1;
l[node]=lvl;
for(auto it:v[node]){
if(!vis[it]){
pa[it]=node;
dfs(it,lvl+1);
}
}
}
//Define pa-parent array, l-level array and dp[N][log(N)]
int lca(int p,int q){
int i;
if(l[p]<l[q]){
int t=p;
p=q;
q=t;
}
int lim;
for(lim=0;(1<<lim)<=l[p];++lim);
lim--;
for(i=lim;i>=0;--i){
if((l[p]-(1<<i))>=l[q])
p=dp[p][i];
}
if(p==q){
return p;
}
for(i=lim;i>=0;--i){
if(dp[p][i]!=-1&&dp[p][i]!=dp[q][i]){
p=dp[p][i];
q=dp[q][i];
}
}
return pa[p];
}
void pre(int n){
int i,j;
for(i=1;i<=n;++i){
dp[i][0]=pa[i];
}
for(i=1;i<=n;i++){
for(j=1;j<25;j++){
if(dp[i][j-1]){
dp[i][j]=dp[dp[i][j-1]][j-1];
}
}
}
}
int dis(int p,int q){
int lc=lca(p,q);
return l[p]-2*l[lc]+l[q];
}
int main(){
int a,b,i,root,p,x,y,z,ans,n,q,node;
cin>>n>>q;
for(i=0;i<n-1;i++){
cin>>a>>b;
v[a].pb(b);
v[b].pb(a);
}
root=1;
pa[root]=0;
dfs(1,0);
trace(i);
pre(n);
for(i=0;i<q;i++){
cin>>x>>y>>z;
p=lca(x,y);
p=lca(p,z);
int ab=lca(y,z);
int bc=lca(z,x);
int ca=lca(x,y);
ans=1e9;
if(dis(p,x)+dis(p,y)+dis(p,z)<ans){
ans=dis(p,x)+dis(p,y)+dis(p,z);
node=p;
}
if(dis(x,y)+dis(x,z)<ans){
ans=dis(x,y)+dis(x,z);
node=x;
}
if(dis(y,z)+dis(y,x)<ans){
ans=dis(y,z)+dis(y,x);
node=y;
}
if(dis(x,z)+dis(z,y)<ans){
ans=dis(x,z)+dis(z,y);
node=z;
}
if(dis(ab,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V09MTsKCWxbbm9kZV09bHZsOwoJZm9yKGF1dG8gaXQ6dltub2RlXSl7CgkJaWYoIXZpc1tpdF0pewoJCQlwYVtpdF09bm9kZTsKCQkJZGZzKGl0LGx2bCsxKTsKCQl9Cgl9Cn0KLy9EZWZpbmUgcGEtcGFyZW50IGFycmF5LCBsLWxldmVsIGFycmF5IGFuZCBkcFtOXVtsb2coTildCmludCBsY2EoaW50IHAsaW50IHEpewogICAgaW50IGk7CiAgICBpZihsW3BdPGxbcV0pewogICAgICAgIGludCB0PXA7CiAgICAgICAgcD1xOwogICAgICAgIHE9dDsKICAgIH0KICAgIAogICAgaW50IGxpbTsKICAgIGZvcihsaW09MDsoMTw8bGltKTw9bFtwXTsrK2xpbSk7CiAgICBsaW0tLTsKICAgIGZvcihpPWxpbTtpPj0wOy0taSl7CiAgICAgICAgaWYoKGxbcF0tKDE8PGkpKT49bFtxXSkKICAgICAgICAgICAgcD1kcFtwXVtpXTsKICAgIH0KICAgIGlmKHA9PXEpewogICAgICAgIHJldHVybiBwOwogICAgfQogICAgZm9yKGk9bGltO2k+PTA7LS1pKXsKICAgICAgICBpZihkcFtwXVtpXSE9LTEmJmRwW3BdW2ldIT1kcFtxXVtpXSl7CiAgICAgICAgICAgIHA9ZHBbcF1baV07CiAgICAgICAgICAgIHE9ZHBbcV1baV07CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIHBhW3BdOwp9CnZvaWQgcHJlKGludCBuKXsKICAgIGludCBpLGo7CiAgICBmb3IoaT0xO2k8PW47KytpKXsKICAgICAgICBkcFtpXVswXT1wYVtpXTsKICAgIH0KICAgIGZvcihpPTE7aTw9bjtpKyspewogICAgCWZvcihqPTE7ajwyNTtqKyspewogICAgCQlpZihkcFtpXVtqLTFdKXsKICAgIAkJCWRwW2ldW2pdPWRwW2RwW2ldW2otMV1dW2otMV07CiAgICAJCX0KICAgIAl9CiAgICB9Cn0KaW50IGRpcyhpbnQgcCxpbnQgcSl7CglpbnQgbGM9bGNhKHAsc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