#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((long long)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
#define cinfast() cin.tie(0), ios::sync_with_stdio(false)
#define PERM(c)                                                                \
    sort(All(c));                                                              \
    for(bool cp = true; cp; cp = next_permutation(All(c)))
#define MKORDER(n)                                                             \
    vector<int> od(n);                                                         \
    iota(All(od), 0LL);

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    long long __VA_ARGS__;                                                     \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dw[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dh[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

ll N, M;
struct edge {
    ll to, col, len;
};
vector<vector<edge>> g;

// rmq build:n query:logn
struct LCA {
    const int lg = 12;
    const int sz = 1 << lg;
    const int ms = sz - 1;
    int n;
    vector<int> P, D, E, A, B, T, ht;
    vector<vector<int>> G, dat;
    LCA(int n)
        : n(n), P(n, -1), D(n), E(n * 2, 0), A(n * 2, -1), B(n * 2 / lg + 1), T(sz, 0), G(n) {}

    void add_edge(int u, int v) {
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    void dfs(int v, int p, int d, int &k) {
        D[v] = k;
        A[k] = P[v] = p;
        E[k++] = d;
        for(int u : G[v])
            if(u != p) dfs(u, v, d + 1, k);
        A[k] = P[v];
        E[k++] = d - 1;
    }

    // if it need leftmost, then add: if(E[i]==E[j]) return i<j?i:j;
    inline int comp(int i, int j) { return E[i] < E[j] ? i : j; };
    inline int comp(int i, int j, int k) { return comp(comp(i, j), k); };

    void build(int r = 0) {
        int k = 0;
        dfs(r, -1, 1, k);

        B[0] = 1;
        for(int i = 1; i < n * 2; i++)
            B[i / lg] |= (E[i - 1] < E[i]) << (i % lg);

        for(int b = 0; b < sz; b++) {
            int e = 0, w = 1, &x = T[b];
            for(int i = 0; i < lg; i++) {
                if((b >> i) & 1)
                    e++;
                else
                    e--;
                if(e < w) e = w, x = i;
            }
        }

        int m = (n * 2 + lg - 1) / lg;
        int h = 1;
        while((1 << h) < m) h++;
        dat.assign(h, vector<int>(m, -1));
        ht.assign(m + 1, 0);
        for(int j = 2; j <= m; j++) ht[j] = ht[j >> 1] + 1;

        for(int j = 0; j < n * 2; j++) {
            if(dat[0][j / lg] < 0) dat[0][j / lg] = j;
            dat[0][j / lg] = comp(dat[0][j / lg], j);
        }

        for(int i = 1, p = 1; i < h; i++, p <<= 1)
            for(int j = 0; j < m; j++)
                dat[i][j] = comp(dat[i - 1][j], dat[i - 1][min(j + p, m - 1)]);
    }

    inline int cs(int a, int b) {
        int l = b - a;
        return comp(dat[ht[l]][a], dat[ht[l]][b - (1 << ht[l])]);
    }

    inline int es(int i, int l, int r) {
        int x = r - i * lg + 1, y = l - i * lg;
        int b = (((B[i] | (ms << x)) >> y) | (ms << (lg - y))) & ms;
        return l + T[b];
    }

    inline int ls(int i, int l) {
        int k = l - i * lg;
        int b = ((B[i] >> k) | (ms << (lg - k))) & ms;
        return l + T[b];
    }

    inline int rs(int j, int r) {
        int k = r - j * lg + 1;
        int b = (B[j] | (ms << k)) & ms;
        return j * lg + T[b];
    }

    inline int rmq(int l, int r) {
        int i = l / lg, j = r / lg;
        if(i == j) return es(i, l, r);
        if(i + 1 == j) return comp(ls(i, l), rs(j, r));
        return comp(ls(i, l), cs(i + 1, j), rs(j, r));
    }

    int lca(int l, int r) {
        if(l == r) return l;
        if(D[l] > D[r]) swap(l, r);
        int x = D[l], y = D[r];
        int m = rmq(x, y);
        return m == x ? l : A[m];
    }

    int distance(int u, int v) {
        return E[D[u]] + E[D[v]] - E[D[lca(u, v)]] * 2;
    }
};

ll ans[100100], clen[100100], ccnt[100100];
struct query {
    ll idx, col, len, mul;
};
vector<vector<query>> qs;

void dfs(ll now, ll par, ll d) {
    FOREACH(q, qs[now]) {
        ll idx = q.idx, col = q.col, len = q.len, mul = q.mul;
        ans[idx] += (d - clen[col] + ccnt[col] * len) * mul;
    }
    FOREACH(e, g[now]) {
        ll to = e.to, col = e.col, len = e.len;
        if(to == par) continue;
        clen[col] += len;
        ccnt[col]++;
        dfs(to, now, d + len);
        clen[col] -= len;
        ccnt[col]--;
    }
}

signed main() {
    cinfast();
    LCIN(N, Q);
    LCA hld(N);
    g.resize(N);
    REP(i, N - 1) {
        LCIN(a, b, c, d);
        a--, b--;
        g[a].push_back({b, c, d});
        g[b].push_back({a, c, d});
        hld.add_edge(a, b);
    }
    hld.build();
    qs.resize(N);
    REP(i, Q) {
        LCIN(x, y, u, v);
        u--, v--;
        qs[u].push_back({i, x, y, 1});
        qs[v].push_back({i, x, y, 1});
        qs[hld.lca(u, v)].push_back({i, x, y, -2});
    }
    dfs(0, -1, 0);
    REP(i, Q) { cout << ans[i] << "\n"; }
}


Measured memory_bytes: 45808