#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc133/tasks/abc133_f>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

/*
 HL-Decomposition
 */

const int MAXN = 100010;
struct HLD{
    typedef int TYPE;
    typedef pair<TYPE,TYPE> PTT;
    TYPE V; // 頂点数
    TYPE root; // 根の頂点番号
    vector<vector<TYPE>> G;
    // parent : 親
    // Hchild : Heavy Childの頂点番号
    // number : 新しく割り当てた頂点番号
    // id :  割り当て直した数字の元のノード番号 (id[number[pos]] = pos)
    // group : 各ノードが属するグループ番号
    // depth : 各頂点の深さ
    TYPE parent[MAXN];
    TYPE Hchild[MAXN];
    TYPE number[MAXN];
    TYPE id[MAXN];
    TYPE group[MAXN];
    TYPE depth[MAXN];
    
    vector<PTT> paths; // [u,v]間の経路を分解(最大でもlogN)
    vector<PTT> Ledges; // pathsを結ぶライドエッジ
    
    HLD() {root = V = -1; }
    HLD(TYPE V):
    V(V),root(0),G(V){
        fill(parent,parent+V,-1);
        fill(Hchild,Hchild+V,-1);
        fill(number,number+V,-1);
        fill(id,id+V,-1);
        fill(group,group+V,-1);
        fill(depth,depth+V,0);
    }
    void add_edge(TYPE u,TYPE v){ G[u].push_back(v); G[v].push_back(u);}
    void build(TYPE _root = 0){
        root = _root;
        int num = 0;
        dfs1(); init_number(num); dfs2();
    }
    TYPE dfs1(TYPE pos = -1,TYPE pre = -1){
        if(pos == -1) pos = root;
        TYPE maxw = -1, weight = 1;
        for(TYPE next:G[pos]){
            if(next == pre) continue;
            TYPE child_weight = dfs1(next,pos);
            weight += child_weight;
            if(maxw < child_weight){ Hchild[pos] = next; maxw = child_weight; }
        }
        return weight;
    }
    void dfs2(TYPE pos = -1,TYPE pre = -1,TYPE dep = 0,TYPE g = -1){
        if(pos == -1) pos = g = root;
        parent[pos] = pre; depth[pos] = dep; group[pos] = g;
        for(TYPE next:G[pos]){
            if(next == pre) continue;
            dfs2(next,pos,dep+1,Hchild[pos]==next?g:next);
        }
    }
    void init_number(int& num,TYPE pos = -1,TYPE pre = -1){
        if(pos == -1) pos = root;
        number[pos] = num++;
        id[number[pos]] = pos;
        if(Hchild[pos] >= 0) init_number(num,Hchild[pos],pos);
        for(TYPE next:G[pos]){
            if(next != pre && next != Hchild[pos]) init_number(num,next,pos);
        }
    }
    
    void buildPaths(TYPE u,TYPE v){
        if(depth[group[u]] < depth[group[v]]) swap(u,v);
        TYPE num_u=number[u], num_v=number[v];
        if(same(u,v)){ paths.push_back({min(num_u,num_v),max(num_u,num_v)}); return;}
        TYPE group_u = group[u];
        buildPaths(parent[group_u],v);
        paths.push_back({number[group_u], number[u]});
        Ledges.push_back({number[parent[group_u]], number[group_u]});
    }
    
    TYPE lca(TYPE u,TYPE v){
        if(depth[group[u]] < depth[group[v]]) swap(u,v);
        if(same(u,v)) return depth[u] < depth[v]?u:v;
        return lca(parent[group[u]],v);
    }
    TYPE distance(TYPE u,TYPE v){
        return depth[u] + depth[v] - 2*depth[lca(u,v)];
    }
    
    // u<->vへのパス、u<->vをつなぐライトエッジを返却
    pair<vector<PTT>,vector<PTT>> getPath(TYPE u,TYPE v){
        paths.clear(); Ledges.clear();
        buildPaths(u,v);
        return make_pair(paths,Ledges);
    }
    bool same(TYPE a,TYPE b){return group[a] == group[b];}
};


template <typename Monoid>
struct SegmentTree {
public:
    using Type = typename Monoid::Type;
    int sz; // Array size
    vector<Type>node;
    SegmentTree(int n){
        sz = 1;
        while(sz < n) sz <<= 1;
        node.assign(2*sz,Monoid::id());
    }
    void set(int k,const Type& val){
        node[k+sz] = val;
    }
    void build(){
        for(int k = sz - 1; k > 0; k--){
            node[k] = Monoid::op(node[2*k],node[2*k+1]);
        }
    }
    inline void update(int k, const Type& val) {
        k += sz;
        node[k] = val;
        while (k >>= 1) {
            node[k] = Monoid::op(node[2*k], node[2*k+1]);
        }
    }
    inline Type query(int l, int r) {
        if (l >= r)return Monoid::id();
        Type vl = Monoid::id(), vr = Monoid::id();
        for (l += sz, r += sz; l != r; l >>= 1, r >>= 1) {
            if (l & 1)  vl = Monoid::op(vl, node[l++]);
            if (r & 1)  vr = Monoid::op(node[--r], vr);
        }
        return Monoid::op(vl, vr);
    }
    Type operator[](int i) { return node[i + sz]; }
};

struct Monoid {
    using Type = pll;/* Monoidに乗せる型 */
    static Type id() { return Type(); /* モノイドの初期値 */};
    
    // ================================================ //
    //                              マージ処理                               //
    // ================================================ //
    static Type op(const Type&l, const Type &r) {
        Type ret;
        
        ret.first = l.first + r.first;
        ret.second = l.second + r.second;
        
        return ret;
    }
};

using Item3 = tuple<int,int,int>;
vector<Item3> Color[100010];
map<pii,pii> G;
pii edges[100010];

using Item4 = tuple<int,int,int,int>;
vector<Item4> Qs[100010];


template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    int Q; cin >> Q;
    
    HLD hld(N);
    for(int i = 0; i < N-1;i++){
        int a,b,c,d; cin >> a >> b >> c >> d;
        a--; b--;
        if(a > b) swap(a,b);
        G[pii(a,b)] = pii(c,d);
        hld.add_edge(a, b);
        Color[c].push_back(Item3(a,b,d));
    }
    hld.build();
    
    for(int i = 1; i < N;i++){
        int pn = (int)hld.parent[i];
        int n = i;
        if(pn > n) swap(pn,n);
        edges[hld.number[i]] = G[pii(pn,n)];
        
    }
    
    SegmentTree<Monoid> ST(N);
    for(int i = 1; i < N;i++){
        ST.set(i,pll(edges[i].second,0));
    }
    ST.build();
    
    for(int i = 0; i < Q;i++){
        int x,y,u,v; cin >> x >> y >> u >> v;
        u--; v--;
        Qs[x].push_back(Item4(y,u,v,i));
    }
    
    vector<ll> ans(Q);
    
    for(int c = 1; c <= N; c++){
        for(auto e:Color[c]){
            int l,r; tie(l,r,ignore) = e;
            
            if(l != hld.parent[r]) swap(l,r);
            int i = hld.number[r];
            ST.update(i,pll(0,1));
        }
        
        for(auto query:Qs[c]){
            int y,u,v,i; tie(y,u,v,i) = query;
            
            auto ps = hld.getPath(u, v).first;
            ps[0].first++;
            
            ll dist_sum = 0;
            ll c_cnt = 0;
            for(auto p:ps){
                auto ret = ST.query(p.first, p.second+1);
                
                dist_sum += ret.first;
                c_cnt += ret.second;
            }
            
            ans[i] = dist_sum + c_cnt * y;
        }
        
        for(auto e:Color[c]){
            int l,r,d; tie(l,r,d) = e;
            
            if(l != hld.parent[r]) swap(l,r);
            int i = hld.number[r];
            ST.update(i,pll(d,0));
        }
    }
    for(auto a:ans){
        cout << a << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 51124