#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

class HLDecomposition{
private:
    std::vector<std::vector<int_fast32_t>> G;
    std::vector<int_fast32_t> vid, inv, dep, par, typ, sub, head, in, out;
    size_t n, pos;
public:
    HLDecomposition(){}
    HLDecomposition(size_t n):
            n(n), pos(0), G(n), vid(n, -1), inv(n), dep(n, -1),
            par(n), typ(n), sub(n, 1), head(n), in(n, -1), out(n, -1){}

    void add_edge(uint_fast32_t u, uint_fast32_t v){
        G[u].push_back(v);
        G[v].push_back(u);
    }

    void build(){
        uint_fast32_t type = 0;
        for(int_fast32_t i = 0;i < n;i++){
            if(dep[i] == -1){
                dfs(i);
                dfs2(i, type++, i);
            }
        }
    }

    void dfs(uint_fast32_t v){
        using T = std::pair<uint_fast32_t, uint_fast32_t>;
        dep[v] = 0;
        par[v] = -1;
        std::stack<T> st;
        st.emplace(v, 0);
        while(st.size()){
            v = st.top().first;
            uint_fast32_t &i = st.top().second;
            if(i<G[v].size()){
                uint_fast32_t u = G[v][i++];
                if(u == par[v]) continue;
                par[u] = v;
                dep[u] = dep[v]+1;
                st.emplace(u, 0);
            }else{
                st.pop();
                for(int_fast32_t &u : G[v]){
                    if(u == par[v]) continue;
                    sub[v] += sub[u];
                    if(G[v][0] == par[v] || sub[u] > sub[G[v][0]]){
                        std::swap(u, G[v][0]);
                    }
                }
            }
        }
    }

    void dfs2(uint_fast32_t v, uint_fast32_t t, uint_fast32_t h){
        typ[v] = t;
        in[v] = pos;
        out[v] = in[v]+sub[v]-1;
        vid[v] = pos++;
        inv[vid[v]] = v;
        head[v] = h;
        for(uint_fast32_t u : G[v]){
            if(u == par[v]) continue;
            if(u == G[v][0])
                dfs2(u, t, h);
            else
                dfs2(u, t, u);
        }
    }

    void for_each(uint_fast32_t u, uint_fast32_t v, const std::function<void(uint_fast32_t, uint_fast32_t)>& f){
        while(1){
            if(vid[u] > vid[v]) std::swap(u, v);
            f(std::max(vid[head[v]], vid[u]), vid[v]);
            if(head[u] != head[v]) v=par[head[v]];
            else break;
        }
    }

    void for_each_edge(uint_fast32_t u, uint_fast32_t v, const std::function<void(uint_fast32_t, uint_fast32_t)>& f){
        while(1){
            if(vid[u] > vid[v]) std::swap(u, v);
            if(head[u] != head[v]){
                f(vid[head[v]], vid[v]);
                v = par[head[v]];
            }else{
                if(u!=v) f(vid[u]+1, vid[v]);
                break;
            }
        }
    }

    void for_subtree(uint_fast32_t u, const std::function<void(uint_fast32_t, uint_fast32_t)>& f){
        if(in[u] == -1){
            std::cout << "Invalid vertex." << std::endl;
            return;
        }
        f(in[u], out[u]);
    }

    uint_fast32_t lca(uint_fast32_t u, uint_fast32_t v){
        while(1){
            if(vid[u] > vid[v]) std::swap(u, v);
            if(head[u] != head[v]) v = par[head[v]];
            else return u;
        }
    }

    uint_fast32_t distance(uint_fast32_t u, uint_fast32_t v){
        uint_fast32_t ret = dep[u]+dep[v]-2*dep[lca(u, v)];
        assert(ret >= 0);
        return ret;
    }

    uint_fast32_t getvid(uint_fast32_t v){
        return vid[v];
    }
};
template<class ValueMonoid, template<class...> class Container=::std::vector>
class SegTree{
public:
    using value_structure = ValueMonoid;
    using value_type = typename value_structure::value_type;
    using const_reference = const value_type &;
    using container_type = Container<value_type>;
    using size_type = typename container_type::size_type;

private:
    ::std::vector<value_type> tree;
    size_type size_;

    static size_type getsize(const size_type x){
        size_type ret = 1;
        while(ret < x)
            ret <<= 1;
        return ret;
    }

    inline value_type calc(const value_type a, const value_type b){
        return value_structure::operation(a, b);
    }

    inline void calc_node(const size_type index){
        if(tree.size() <= (index << 1 | 1)) return;
        tree[index] = value_structure::operation(tree[index<<1], tree[index<<1 | 1]);
    }
public:
    SegTree() : size_(0), tree(){}
    SegTree(const size_type size)
            : size_(size), tree(size << 1, value_structure::identity()){}
    template<class InputIterator>
    SegTree(InputIterator first, InputIterator last)
            : size_(::std::distance(first, last)){
        tree = container_type(size_, value_structure::identity());
        tree.insert(tree.end(), first, last);
        for(size_type i = size_;i > 0;i--){
            calc_node(i);
        }
    }

    size_type size() const { return size_; }
    const_reference operator[](const size_type k) const {
        assert(k < size_);
        return tree[k+size_];
    }

    value_type query(size_type l, size_type r){
        assert(l <= r);
        assert(0 <= l && l < size_);
        assert(0 <= r && r <= size_);
        value_type retl = value_structure::identity(), retr = value_structure::identity();
        for(l += size_, r += size_; l < r ; l >>= 1, r >>= 1){
            if(l&1) retl = calc(retl, tree[l++]);
            if(r&1) retr = calc(tree[--r], retr);
        }
        return calc(retl, retr);
    }

    template<class F>
    void update(size_type index, const F& f){
        assert(0 <= index && index < size());
        index += size_;
        tree[index] = f(::std::move(tree[index]));
        while(index >>= 1)
            calc_node(index);
    }

    /*
    template<class F>
    size_type search(const F& f) const { // [0, result) is True and [0, result-1) is not.
        if(f(value_structure::identity()))
            return 0;
        if(!f(tree[1]))
            return size_+1;
        value_type acc = value_structure::identity();
        size_type i = 1;
        while(i <
    }
    */
};


class v_monoid {
public:
    using value_type = int64;
    static value_type identity() { return 0; }
    static value_type initializer() { return 0; }
    static value_type operation(const int64& l, const int64& r) {
        return l + r;
    }
};

constexpr int64 mod = 1e9+7;

int main(void) {
    int64 N, Q;
    cin >> N >> Q;

    SegTree<v_monoid> sg1(N+1), sg2(N+1);
    HLDecomposition hld(N);
    using T = tuple<int64, int64, int64>;
    using U = tuple<int64, int64, int64, int64>;
    vector<vector<T>> edge(N);
    vector<vector<U>> query(N);
    REP(i, N-1) {
        int64 a, b, c, d;
        cin >> a >> b >> c >> d; a--; b--; c--;
        edge[c].emplace_back(a, b, d);
        hld.add_edge(a, b);
    }
    hld.build();

    REP(i, N-1) {
        int64 a, b, c, d;
        REP(j, edge[i].size()) {
            tie(a, b, d) = edge[i][j];
            hld.for_each_edge(a, b, [&](int64 a, int64 b) {sg1.update(a, [&](int64 x) { return d; });});
        }
    }

    REP(i, Q) {
        int64 x, y, u, v;
        cin >> x >> y >> u >> v; u--; v--; x--;
        query[x].emplace_back(u, v, y, i);
    }

    vector<int64> res(Q);
    REP(i, N-1) {
        REP(j, edge[i].size()) {
            int64 a, b, d;
            tie(a, b, d) = edge[i][j];
            hld.for_each_edge(a, b, [&](int64 a, int64 b){sg1.update(a, [](int64 x){return 0;});});
            hld.for_each_edge(a, b, [&](int64 a, int64 b){sg2.update(a, [&](int64 x){return 1;});});
        }
        REP(j, query[i].size()) {
            int64 u, v, x, id;
            tie(u, v, x, id) = query[i][j];
            int64 sum = 0;
            hld.for_each_edge(u, v, [&](int64 a, int64 b) {sum += sg1.query(a, b+1);});
            res[id] = sum; sum = 0;
            hld.for_each_edge(u, v, [&](int64 a, int64 b) {sum += sg2.query(a, b+1);});
            res[id] += sum * x;
        }
        REP(j, edge[i].size()) {
            int64 a, b, d;
            tie(a, b, d) = edge[i][j];
            hld.for_each_edge(a, b, [&](int64 a, int64 b){sg1.update(a, [&](int64 x){return d;});});
            hld.for_each_edge(a, b, [&](int64 a, int64 b){sg2.update(a, [&](int64 x){return 0;});});
        }
    }
    REP(i, Q) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 51248