#include <iostream>
#include <vector>
using namespace std;


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }



struct Edge {
    int to;
    int c;
    long long d;
    Edge() {}
    Edge(int t, int c, long long d) : to(t), c(c), d(d) {}
};
using Graph = vector<vector<Edge>>;

struct LCA {
    vector<vector<int> > parent; // parent[d][v] := 2^d-th parent of v
    vector<int> depth;
    LCA() { }
    LCA(const Graph &G, int r = 0) { init(G, r); }
    void init(const Graph &G, int r = 0) {
        int V = (int)G.size();
        int h = 1;
        while ((1<<h) < V) ++h;
        parent.assign(h, vector<int>(V, -1));
        depth.assign(V, -1);
        dfs(G, r, -1, 0);
        for (int i = 0; i+1 < (int)parent.size(); ++i)
            for (int v = 0; v < V; ++v)
                if (parent[i][v] != -1)
                    parent[i+1][v] = parent[i][parent[i][v]];
    }
    void dfs(const Graph &G, int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (auto e : G[v]) if (e.to != p) dfs(G, e.to, v, d+1);
    }
    int get(int u, int v) {
        if (depth[u] > depth[v]) swap(u, v);
        for (int i = 0; i < (int)parent.size(); ++i)
            if ( (depth[v] - depth[u]) & (1<<i) )
                v = parent[i][v];
        if (u == v) return u;
        for (int i = (int)parent.size()-1; i >= 0; --i) {
            if (parent[i][u] != parent[i][v]) {
                u = parent[i][u];
                v = parent[i][v];
            }
        }
        return parent[0][u];
    }
};

int N, Q;
Graph G;

struct Query {
    int id;
    int c;
    long long d;
    Query() {}
    Query(int i, int c, long long d) : id(i), c(c), d(d) {}
};

vector<vector<Query>> ps, ms;
void rec(int v, int p, long long all, vector<long long> &res, vector<long long> &cnum, vector<long long> &call) {
    /*
    COUT(v);
    COUT(all);
    COUT(cnum);
    COUT(call);
    */
    for (auto q : ps[v]) res[q.id] += all - call[q.c] + cnum[q.c] * q.d;
    for (auto q : ms[v]) res[q.id] -= (all - call[q.c] + cnum[q.c] * q.d) * 2;
    for (auto e : G[v]) {
        if (e.to == p) continue;
        cnum[e.c]++, call[e.c] += e.d;
        rec(e.to, v, all+e.d, res, cnum, call);
        cnum[e.c]--, call[e.c] -= e.d;
    }
}

int main() {
    while (cin >> N >> Q) {
        G.assign(N, vector<Edge>());
        for (int i = 0; i < N-1; ++i) {
            int a, b, c; long long d; cin >> a >> b >> c >> d;
            --a, --b;
            G[a].push_back(Edge(b, c, d));
            G[b].push_back(Edge(a, c, d));
        }
        LCA lca(G);
        ps.assign(N, vector<Query>());
        ms = ps;
        for (int q = 0; q < Q; ++q) {
            int c, d, u, v; cin >> c >> d >> u >> v;
            --u, --v;
            int l = lca.get(u, v);
            ps[u].push_back(Query(q, c, d));
            ps[v].push_back(Query(q, c, d));
            ms[l].push_back(Query(q, c, d));
        }
        vector<long long> res(Q, 0), cnum(N, 0), call(N, 0);
        rec(0, -1, 0, res, cnum, call);
        for (auto r : res) cout << r << endl;
    }
}


Measured memory_bytes: 36340