#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#define rep(i,j,k) for (int (i)=(j);(i)<=(k);++(i))
using namespace std;
typedef long long ll;
const int L=20,N=(int)1e5;
bool invalid[N*2+10];
int st[L+10][N*20+10];
int lg[N*20+10],euler[N*20+10];
ll sumval[N+10],minusval[N+10];
vector<pair<int,int> > e[N+10];
int n,Q,mm=1,cnt,ecnt,root,total;
int ed[N*2+10],nxt[N*2+10],cost[N*2+10];
int fa[N+10],id[N+10],anc[N+10],dis[N+10],son[N+10],sum[N+10],size[N+10],maxson[N+10];
inline int getint(){
int x=0;
bool flag=false;
char ch=getchar();
while (!(ch>='0' && ch<='9' || ch=='-')) ch=getchar();
if (ch=='-') flag=true,ch=getchar();
while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return flag?-x:x;
}
inline void addedge(int x,int y,int z){
nxt[++mm]=son[x]; son[x]=mm; ed[mm]=y; cost[mm]=z;
nxt[++mm]=son[y]; son[y]=mm; ed[mm]=x; cost[mm]=z;
}
void dfs(int x,int pre){
euler[++ecnt]=x;
id[x]=ecnt;
for (int i=son[x];i;i=nxt[i])
if (ed[i]!=pre){
anc[ed[i]]=x;
dis[ed[i]]=dis[x]+cost[i];
dfs(ed[i],x);
euler[++ecnt]=x;
}
}
void makelist(){
rep(i,1,ecnt) st[0][i]=dis[euler[i]];
rep(i,2,ecnt) lg[i]=lg[i-1]+(1<<lg[i-1]+1==i);
rep(i,1,lg[ecnt]) rep(j,1,ecnt-(1<<i)+1) st[i][j]=min(st[i-1][j],st[i-1][j+(1<<i-1)]);
}
int getlca(int x,int y){
x=id[x];
y=id[y];
if (x>y) swap(x,y);
int k=lg[y-x+1];
return min(st[k][x],st[k][y-(1<<k)+1]);
}
int getdis(int x,int y){
return dis[x]+dis[y]-2*getlca(x,y);
}
void findroot(int x,int pre){
size[x]=1;
maxson[x]=0;
for (int i=son[x];i;i=nxt[i])
if (ed[i]!=pre && !invalid[i]){
findroot(ed[i],x);
size[x]+=size[ed[i]];
maxson[x]=max(maxson[x],size[ed[i]]);
}
maxson[x]=max(maxson[x],total-size[x]);
if (maxson[x]<maxson[root]) root=x;
}
void work(int x){
for (int i=son[x];i;i=nxt[i])
if (!invalid[i]){
invalid[i^1]=true;
root=0;
total=size[ed[i]];
maxson[0]=size[ed[i]];
findroot(ed[i],0);
e[x].push_back(make_pair(ed[i],root));
fa[root]=x;
work(root);
}
}
inline void update(int u,int e){
for (int i=u;i;i=fa[i]){
sum[i]+=e;
sumval[i]+=(ll)e*getdis(u,i);
if (fa[i]) minusval[i]+=(ll)e*getdis(u,fa[i]);
}
}
inline ll calc(int x){
ll ans=sumval[x];
for (int i=x;fa[i];i=fa[i]){
ans+=sumval[fa[i]]-minusval[i];
ans+=(ll)(sum[fa[i]]-sum[i])*getdis(x,fa[i]);
}
return ans;
}
inline ll query(int x){
ll y=calc(x);
for (vector<pair<int,int> >::iterator i=e[x].begin();i!=e[x].end();++i)
if (calc(i->first)<y) return query(i->second);
return y;
}
int main(){
n=getint(); Q=getint();
rep(i,2,n){
int x=getint(),y=getint(),z=getint();
addedge(x,y,z);
}
dfs(1,0);
makelist();
root=0;
total=n;
maxson[0]=n;
findroot(1,0);
int start=root;
work(root);
while (Q--){
int u=getint(),e=getint();
update(u,e);
printf("%lld\n",query(start));
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxhbGdvcml0aG0+CgojZGVmaW5lIHJlcChpLGosaykgZm9yIChpbnQgKGkpPShqKTsoaSk8PShrKTsrKyhpKSkKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmNvbnN0IGludCBMPTIwLE49KGludCkxZTU7Cgpib29sIGludmFsaWRbTioyKzEwXTsKaW50IHN0W0wrMTBdW04qMjArMTBdOwppbnQgbGdbTioyMCsxMF0sZXVsZXJbTioyMC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