#include<cstdio>
#include<cctype>
#include<queue>
#include<cstring>
#include<algorithm>
#define rep(s,t) for(int i=s;i<=t;i++)
#define ren for(int i=first[x];i;i=next[i])
#define ren2 for(int i=first2[x];i;i=next2[i])
using namespace std;
inline int read() {
int x=0,f=1;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c==‘-‘) f=-1;
for(;isdigit(c);c=getchar()) x=x*10+c-‘0‘;
return x*f;
}
typedef long long LL;
const int maxn=200010;
int n,m,first[maxn],next[maxn],es;
struct Edge {int to,dist;}edges[maxn];
void AddEdge(int w,int v,int u) {
edges[++es]=(Edge){v,w};next[es]=first[u];first[u]=es;
edges[++es]=(Edge){u,w};next[es]=first[v];first[v]=es;
}
int first2[maxn],next2[maxn],to[maxn],num[maxn],es2;
void AddEdge2(int u,int v,int w) {
to[++es2]=v;num[es2]=w;next2[es2]=first2[u];first2[u]=es2;
}
int mn[maxn][21],Log[maxn],pos[maxn],dep[maxn],cnt;
void dfs(int x,int fa) {
mn[++cnt][0]=dep[x];pos[x]=cnt;
ren {
Edge& e=edges[i];
if(e.to!=fa) {
dep[e.to]=dep[x]+e.dist;dfs(e.to,x);
mn[++cnt][0]=dep[x];
}
}
}
int dist(int x,int y) {
int ans=dep[x]+dep[y],k;
x=pos[x];y=pos[y];if(x>y) swap(x,y);
k=Log[y-x+1];return ans-min(mn[x][k],mn[y-(1<<k)+1][k])*2;
}//In order to get the LCA of x and y for nlogn times,we should use the "LCA-RMQ algorithm" to calculate.
int root,size,s[maxn],f[maxn],vis[maxn];
void getroot(int x,int fa) {
s[x]=1;int maxs=0;
ren {
Edge& e=edges[i];
if(!vis[e.to]&&e.to!=fa) getroot(e.to,x),s[x]+=s[e.to],maxs=max(maxs,s[e.to]);
}
f[x]=max(maxs,size-s[x]);
if(f[root]>f[x]) root=x;
}
int fa[maxn];
void solve(int x,int F) {
vis[x]=1;fa[x]=F;
ren {
Edge& e=edges[i];
if(!vis[e.to]) {
size=f[0]=s[e.to];getroot(e.to,root=0);
AddEdge2(x,root,e.to);
solve(root,x);
}
}
}
LL sum[maxn],dis1[maxn],dis2[maxn];
//sum1[x]=sigma(y‘s val) | y is included in x‘s subtree.
//dis1[x]=sigma(dist(x,y)) | y is included in x‘s subtree.
//dis2[x]=sigma(dist(fa[x],y)) | y is included in x‘s subtree.
void add(int x,int v) {
sum[x]+=v;
for(int i=x;fa[i];i=fa[i]) {
int d=dist(fa[i],x);
dis1[fa[i]]+=(LL)d*v;
dis2[i]+=(LL)d*v;
sum[fa[i]]+=v;
}
}
LL cal(int x) {
LL ret=dis1[x];
for(int i=x;fa[i];i=fa[i]) {
int d=dist(fa[i],x);
ret+=dis1[fa[i]]-dis2[i];
ret+=d*(sum[fa[i]]-sum[i]);
}
return ret;
}
LL query(int x) {
LL ans=cal(x);
ren2 {
LL tmp=cal(num[i]);// Consider x‘s subnode y in previous tree, if the result is smaller than x then the center of gravity must be in y‘s conquer ‘s tree.
if(tmp<ans) return query(to[i]);
}
return ans;
}
int main() {
n=read();m=read();
rep(1,n-1) AddEdge(read(),read(),read());
dfs(1,0);Log[0]=-1;
rep(1,cnt) Log[i]=Log[i>>1]+1;
for(int j=1;(1<<j)<=cnt;j++)
for(int i=1;i+(1<<j)-1<=cnt;i++)
mn[i][j]=min(mn[i][j-1],mn[i+(1<<j-1)][j-1]);//pre-process
size=f[0]=n;getroot(1,root=0);
int t=root;solve(root,0);root=t;
while(m--) {
int x=read(),v=read();
add(x,v);
printf("%lld\n",query(root));
}
return 0;
}