#include<bits/stdc++.h>
const int maxn=4e5;
inline const void read(int &a)
{
a=0;
char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
inline const void write(int a)
{
if(a>9)write(a/10);
putchar(a%10+'0');
}
int n,m,d=0,l=0;
int deep[maxn],point[maxn],next[maxn],to[maxn],len[maxn],belong[maxn],f[maxn],father[maxn],fatherside[maxn];
int lca[maxn],exist[maxn],askto[maxn],askpoint[maxn],asknext[maxn],askbelong[maxn],start[maxn],end[maxn];
bool been[maxn];
inline const void add(int a,int b,int c)
{
next[++d]=point[a];
point[a]=d;
to[d]=b;
len[d]=c;
}
inline const void askadd(int a,int b,int c)
{
asknext[++l]=askpoint[a];
askpoint[a]=l;
askto[l]=b;
askbelong[l]=c;
}
inline const int check(int p)
{
if(p==belong[p])return p;
else return belong[p]=check(belong[p]);
}
const void tarjan(int p)
{
been[p]=true;
int side=point[p];
while(side)
{
if(!been[to[side]])
{
father[to[side]]=p;
fatherside[to[side]]=side;
deep[to[side]]=deep[p]+1;
tarjan(to[side]);
f[p]+=f[to[side]]+len[side];
belong[to[side]]=p;
}
side=next[side];
}
side=askpoint[p];
while(side)
{
if(been[askto[side]])lca[askbelong[side]]=check(askto[side]);
side=asknext[side];
}
}
inline const int solve(int i)
{
int s=start[i],e=end[i];
if(lca[i]==end[i])
{
int k=deep[s]-deep[lca[i]],j=0;
k=k-k/2;
while(k){k--;s=father[s];}
return f[s];
}
if(lca[i]==start[i])
{
int k=deep[e]-deep[lca[i]],j=0;
k=k/2;
e=end[i];
while(k){k--;e=father[e];}
return f[1]-f[e];
}
else
{
int k=deep[s]-deep[lca[i]],p=deep[e]-deep[lca[i]],r=k+p;
k=r-r/2;p=r/2;
while(k&&s!=lca[i]){k--;s=father[s];}
if(k)
{
std::stack<int>path;
while(e!=lca[i]){path.push(e);e=father[e];}
while(k)
{
s=path.top();
path.pop();
k--;
}
return f[1]-f[s];
}
else
{
if(s==lca[i])
{
while(father[e]!=lca[i])e=father[e];
return f[1]-f[e]-len[fatherside[e]];
}
else return f[s];
}
}
}
int main()
{
memset(been,false,sizeof(been));
memset(point,0,sizeof(point));
memset(askpoint,0,sizeof(askpoint));
read(n);read(m);
for(int i=1;i<=n;i++)belong[i]=i;
int x,y,z;
for(int i=1;i<=n-1;i++)
{
read(x);read(y);read(z);
add(x,y,z);add(y,x,z);
}
for(int i=1;i<=m;i++)
{
read(start[i]);read(end[i]);
askadd(start[i],end[i],i);
askadd(end[i],start[i],i);
}
deep[1]=0;
tarjan(1);
for(int i=1;i<=m;i++){write(solve(i));printf("\n");}
return 0;
}