#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;
const int maxn=100010;
typedef long long ll;
const ll inf=123456789123456789ll;
int n,m,cnt;
int to[maxn<<1],next[maxn<<1],val[maxn<<1],head[maxn],dep[maxn],siz[maxn],son[maxn],top[maxn],fa[maxn];
int p[maxn],q[maxn];
ll sa[maxn<<2],sb[maxn<<2],sl[maxn<<2],sr[maxn<<2],sn[maxn<<2],dis[maxn];
inline int rd()
{
int ret=0,f=1; char gc=getchar();
while(gc<‘0‘||gc>‘9‘) {if(gc==‘-‘) f=-f; gc=getchar();}
while(gc>=‘0‘&&gc<=‘9‘) ret=ret*10+(gc^‘0‘),gc=getchar();
return ret*f;
}
inline void add(int a,int b,int c)
{
to[cnt]=b,val[cnt]=c,next[cnt]=head[a],head[a]=cnt++;
}
void dfs1(int x)
{
siz[x]=1;
for(int i=head[x];i!=-1;i=next[i]) if(to[i]!=fa[x])
{
fa[to[i]]=x,dep[to[i]]=dep[x]+1,dis[to[i]]=dis[x]+val[i],dfs1(to[i]),siz[x]+=siz[to[i]];
if(siz[to[i]]>siz[son[x]]) son[x]=to[i];
}
}
void dfs2(int x,int tp)
{
top[x]=tp,p[x]=++q[0],q[q[0]]=x;
if(son[x]) dfs2(son[x],tp);
for(int i=head[x];i!=-1;i=next[i]) if(to[i]!=fa[x]&&to[i]!=son[x]) dfs2(to[i],to[i]);
}
void build(int l,int r,int x)
{
sn[x]=sb[x]=inf;
if(l==r)
{
sl[x]=sr[x]=dis[q[l]];
return ;
}
int mid=(l+r)>>1;
build(l,mid,lson),build(mid+1,r,rson);
sl[x]=sl[lson],sr[x]=sr[rson];
}
void updata(int l,int r,int x,int a,int b,ll c,ll d)
{
int mid=(l+r)>>1;
if(a<=l&&r<=b)
{
if(sl[x]*sa[x]+sb[x]>sl[x]*c+d&&sr[x]*sa[x]+sb[x]>sr[x]*c+d) sa[x]=c,sb[x]=d;
else if(sl[x]*sa[x]+sb[x]>sl[x]*c+d||sr[x]*sa[x]+sb[x]>sr[x]*c+d)
updata(l,mid,lson,a,b,c,d),updata(mid+1,r,rson,a,b,c,d);
sn[x]=min(sn[x],min(sl[x]*c+d,sr[x]*c+d));
if(l!=r) sn[x]=min(sn[x],min(sn[lson],sn[rson]));
return ;
}
if(a<=mid) updata(l,mid,lson,a,b,c,d);
if(b>mid) updata(mid+1,r,rson,a,b,c,d);
sn[x]=min(sn[x],min(sn[lson],sn[rson]));
return ;
}
ll query(int l,int r,int x,int a,int b)
{
if(a<=l&&r<=b) return sn[x];
ll ret=min(dis[q[a]]*sa[x]+sb[x],dis[q[b]]*sa[x]+sb[x]);
int mid=(l+r)>>1;
if(a<=mid) ret=min(ret,query(l,mid,lson,a,min(b,mid)));
if(b>mid) ret=min(ret,query(mid+1,r,rson,max(a,mid+1),b));
return ret;
}
inline int lca(int x,int y)
{
while(top[x]!=top[y])
{
if(dep[top[x]]>dep[top[y]]) x=fa[top[x]];
else y=fa[top[y]];
}
if(dep[x]>dep[y]) return y;
return x;
}
inline void modify()
{
int x=rd(),y=rd();
ll a=rd(),b=rd(),c=dis[x]*a+b,d=(dis[x]-2*dis[lca(x,y)])*a+b;
while(top[x]!=top[y])
{
if(dep[top[x]]>dep[top[y]]) updata(1,n,1,p[top[x]],p[x],-a,c),x=fa[top[x]];
else updata(1,n,1,p[top[y]],p[y],a,d),y=fa[top[y]];
}
if(dep[x]<dep[y]) updata(1,n,1,p[x],p[y],a,d);
else updata(1,n,1,p[y],p[x],-a,c);
}
inline void ask()
{
int x=rd(),y=rd();
ll ret=inf;
while(top[x]!=top[y])
{
if(dep[top[x]]<dep[top[y]]) swap(x,y);
ret=min(ret,query(1,n,1,p[top[x]],p[x])),x=fa[top[x]];
}
if(dep[x]>dep[y]) swap(x,y);
ret=min(ret,query(1,n,1,p[x],p[y]));
printf("%lld\n",ret);
}
int main()
{
n=rd(),m=rd();
int i,a,b,c;
memset(head,-1,sizeof(head));
for(i=1;i<n;i++) a=rd(),b=rd(),c=rd(),add(a,b,c),add(b,a,c);
dep[1]=1,dfs1(1),dfs2(1,1);
build(1,n,1);
for(i=1;i<=m;i++)
{
if(rd()==1) modify();
else ask();
}
return 0;
}//3 5 1 2 10 2 3 20 2 1 3 1 2 3 5 6 2 2 3 1 2 3 -5 -6 2 2 3