#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
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; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

template<typename T> struct Edge {
    int from, to, color;
    T cost;
    Edge(int from, int to, int color, T cost): from(from), to(to), color(color), cost(cost) {}
    Edge(int from, int to, int color): from(from), to(to), color(color), cost(1) {}
    bool operator<(Edge<T> &r) {
        return cost < r.cost;
    }
};
template<typename T>
ostream &operator<<(ostream &os, Edge<T> edge) {
    os << edge.from << " -> " << edge.to << " (" << edge.cost << ")";
    return os;
}

// グラフテンプレート(隣接リスト)
template<typename E = Edge<ll>> struct GraphL {
    // 頂点数、辺数
    int n, m;
    // 隣接リスト
    vector<vector<E>> adj;
    GraphL(int n)
        : n(n), m(0), adj(n) {}
    
    template<typename... Args>
    void add_edge(int from, int to, Args... args) {
        adj[from].emplace_back(from, to, args...);
        m++;
    }
};
template<typename E = Edge<ll>>
ostream &operator<<(ostream &os, GraphL<E> &graph) {
    os << "V = " << graph.n << ", E = " << graph.m << "\n";
    for(const auto& ev: graph.adj) {
        for(const auto& e: ev) {
            os << e << "\n";
        }
    }
    return os;
}

template<typename E>
vector<E> Euler_Tour(GraphL<E> &graph, int root = 0) {
    vector<E> ret;
    vector<int> visited(graph.n, 0);
    auto dfs = [&](auto& Self, int node) -> void {
        visited[node] = 1;
        for(auto&& e: graph.adj[node]) {
            if(!visited[e.to]) {
                ret.emplace_back(e);
                Self(Self, e.to);
                // rev
                e.cost *= -1;
                ret.emplace_back(e);
                e.cost *= -1;
            }
        }
    };
    dfs(dfs, root);
    return ret;
}

struct LCA {
    // m = [lg(n-1)]
    int m, n;
    vector<vector<int>> ancestor;
    vector<int> depth;
    template<typename E>
    LCA(const GraphL<E> &graph, int root = 0): n(graph.n) {
        assert(graph.n >= 1);
        m = 32 - __builtin_clz(graph.n - 1);
        ancestor.resize(m, vector<int>(n));
        depth.resize(n, -1);
        auto dfs = [&](auto& Self, int node, int parent, int d) -> void {
            ancestor[0][node] = parent;
            depth[node] = d;
            for(const auto& e: graph.adj[node])
                if(depth[e.to] == -1)
                    Self(Self, e.to, node, d + 1);
        };
        dfs(dfs, root, -1, 0);
        for(int i = 1; i < m; i++) {
            for(int j = 0; j < n; j++) {
                if(ancestor[i - 1][j] == -1) {
                    ancestor[i][j] = -1;
                } else {
                    ancestor[i][j] = ancestor[i - 1][ancestor[i - 1][j]];
                }
            }
        }
    }
    int query(int node1, int node2) {
        if(depth[node1] > depth[node2]) swap(node1, node2);
        for(int i = m - 1; i >= 0; i--)
            if(((depth[node2] - depth[node1]) >> i) & 1)
                node2 = ancestor[i][node2];
        if(node1 == node2) return node1;
        for(int i = m - 1; i >= 0; i--) {
            if(ancestor[i][node1] != ancestor[i][node2]) {
                node1 = ancestor[i][node1];
                node2 = ancestor[i][node2];
            }
        }
        return ancestor[0][node1];
    }
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, q;
    cin >> n >> q;
    GraphL<> g(n);
    vll a(n-1), b(n-1), c(n-1), d(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--, c[i]--;
        g.add_edge(a[i], b[i], c[i], d[i]);
        g.add_edge(b[i], a[i], c[i], d[i]);
    }
    LCA lca(g);
    vll x(q), y(q), u(q), v(q);
    rep(i, q){
        cin >> x[i] >> y[i] >> u[i] >> v[i];
        x[i]--, u[i]--, v[i]--;
    }
    vector<vp> et(n, vp(1, pll(-1, 0)));
    vector<vp> et_num(n, vp(1, pll(-1, 0)));
    vll edge_num(n, -1);
    auto etall = Euler_Tour(g);
    {
        ll i = 0;
        for(auto&& e: etall){
            et[e.color].emplace_back(i, e.cost);
            et_num[e.color].emplace_back(i, e.cost > 0 ? 1 : -1);
            if(edge_num[e.to] == -1) edge_num[e.to] = i;
            i++;
        }
    }
    rep(i, n){
        repr(j, 1, SZ(et[i])){
            et[i][j].second += et[i][j-1].second;
            et_num[i][j].second += et_num[i][j-1].second;
        }
    }
    vll dist(n);
    vector<int> visited(n, 0);
    auto dfs = [&](auto& Self, int node, ll d) -> void {
        visited[node] = 1;
        dist[node] = d;
        for(auto&& e: g.adj[node]) {
            if(!visited[e.to]) {
                Self(Self, e.to, d + e.cost);
            }
        }
    };
    dfs(dfs, 0, 0);
    dump(edge_num);
    dump(et);
    dump(et_num);
    dump(etall);
    rep(i, q){
        dump(x[i], y[i], u[i], v[i]);
        ll r = lca.query(u[i], v[i]);
        ll ans = dist[u[i]] + dist[v[i]] - 2*dist[r];
        dump(et[x[i]]);
        auto itru = --upper_bound(ALL(et[x[i]]), pll(edge_num[u[i]], INF));
        auto itrv = --upper_bound(ALL(et[x[i]]), pll(edge_num[v[i]], INF));
        auto itrr = --upper_bound(ALL(et[x[i]]), pll(edge_num[r], INF));
        auto itrun = --upper_bound(ALL(et_num[x[i]]), pll(edge_num[u[i]], INF));
        auto itrvn = --upper_bound(ALL(et_num[x[i]]), pll(edge_num[v[i]], INF));
        auto itrrn = --upper_bound(ALL(et_num[x[i]]), pll(edge_num[r], INF));
        dump(*itrun, y[i], *itru);
        dump(*itrvn, y[i], *itrv);
        dump(*itrrn, y[i], *itrr);
        ans += (*itrun).second * y[i] - (*itru).second;
        ans += (*itrvn).second * y[i] - (*itrv).second;
        ans -= 2*((*itrrn).second * y[i] - (*itrr).second);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 55532