#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=2e5+5,K=330,LOGN=17;
int to[N],col[N],len[N],sum[N],cc[N],sumk[N][350],cntk[N][350];
vector<int> cs;
vector<int> g[N];
vector<int> w[N];
int ancestor[N][LOGN];
int tin[N], tout[N];
bool used[N];
int timer = 0;
void lcadfs(int v, int from = -1,int kak=0) {
    used[v] = true;
    ancestor[v][0] = from == -1 ? v : from;
    tin[v] = timer++;
    if(from!=-1){
        sum[v]=sum[from]+len[kak];
        forn(i,cs.size()){
            sumk[v][i]=sumk[from][i];
            cntk[v][i]=cntk[from][i];
        }
        if(cc[col[kak]]>=K){
            int x=lower_bound(cs.begin(), cs.end(),col[kak])-cs.begin();
            sumk[v][x]+=len[kak];
            cntk[v][x]++;
        }
    }
    for (int num : g[v])
        if (!used[to[num]]) 
            lcadfs(to[num],v,num);
    tout[v] = timer++;
}

bool is_ancestor(int u, int v) {
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v) {
    if (is_ancestor(u, v)) return u;     
    for (int i = LOGN - 1; i >= 0; --i)
        if (!is_ancestor(ancestor[u][i], v))
            u = ancestor[u][i];
    return ancestor[u][0];
}

void build(int n) {
    lcadfs(1);
    for (int j = 1; j < LOGN; ++j)
        for (int i = 1; i <= n; ++i)
            ancestor[i][j] = ancestor[ancestor[i][j-1]][j-1];
}


int32_t main(){
    int n,q,m=0;
    cin>>n>>q;
    forn(i,n-1){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        w[c].pb(m);
        to[m]=b;col[m]=c;len[m]=d;
        g[a].pb(m);
        m++;
        to[m]=a;col[m]=c;len[m]=d;
        g[b].pb(m);
        m++;
        cc[c]++;
    }
    forn(i,n)if(cc[i]>=K)cs.pb(i);
    build(n);
    while(q--){
        int x,y,u,v;
        cin>>x>>y>>u>>v;
        int l=lca(u,v);
        int ans=sum[u]+sum[v]-sum[l]*2;
        if(cc[x]>=K){
            int i=lower_bound(cs.begin(), cs.end(),x)-cs.begin();
            // dbg(i);
            int extra=sumk[u][i]+sumk[v][i]-sumk[l][i]*2;
            ans-=extra;
            int stalo=(cntk[u][i]+cntk[v][i]-cntk[l][i]*2)*y;
            ans+=stalo;
        }else{
            for(int e:w[x]){
                int a=to[e],b=to[e+1];
                dbg(a,b,l,u,v);
                if(is_ancestor(l,a)&&is_ancestor(l,b)&&((is_ancestor(a,u)&&is_ancestor(b,u))||(is_ancestor(a,v)&&is_ancestor(b,v)))){
                    ans-=len[e];
                    ans+=y;
                }
            }
        }
        cout<<ans<<'\n';
        // dbg("=====");
    }


    return 0;
}


Measured memory_bytes: 593016