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

#define fs first
#define sc second
#define th third

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


// std::vector Declaration
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...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, color, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

// trio (first, second, third)
template<typename T, typename U, typename V>
struct trio {
    T first;
    U second;
    V third;

    bool operator<(const trio<T,U,V>& rhs) const {
        //pair<T,pair<U,V>> l{first,{second,third}},
        //    r{rhs.first,{rhs.second,rhs.third}};
        //return l < r;
        return first < rhs.first;
    }

    bool operator>(const trio<T,U,V>& rhs) const {
        return rhs < *this;
    }
};

template<typename T, typename U, typename V>
trio<T, U, V> make_trio(T t, U u, V v) {
    return trio<T, U, V>{ t, u, v };
}

// trio Debug
template<typename T, typename U, typename V>
ostream& operator<<(ostream& os, const trio<T, U, V>& t) {
    os << "(" << t.first << " " << t.second << " " << t.third << ")";
    return os;
}

class lca {
public:
    const int n = 0;
    const int log2_n = 0;
    std::vector<std::vector<int>> parent;
    std::vector<int> depth;

    using Graph = vector<vector<edge>>;

    lca() {}

    lca(const Graph &g, int root)
        : n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n) {
        dfs(g, root, -1, 0);
        for (int k = 0; k + 1 < log2_n; k++) {
            for (int v = 0; v < (int)g.size(); v++) {
                if (parent[k][v] < 0)
                    parent[k + 1][v] = -1;
                else
                    parent[k + 1][v] = parent[k][parent[k][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]) std::swap(u, v);
        for (int k = 0; k < log2_n; k++) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = parent[k][v];
            }
        }
        if (u == v) return u;
        for (int k = log2_n - 1; k >= 0; k--) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};

// class LCA {
//     private:
//     int n, log2_n;
//     vector<vector<int>> ancestor;
//     vector<int> depth;
//
//     void dfs(const auto& G, int v, int p, int d) {
//         ancestor[0][v] = p;
//         depth[v] = d;
//         for (auto e : G[v]) {
//             if (e.to != p) dfs(G, e.to, v, d+1);
//         }
//     }
//
//     public:
//     LCA(const vector<vector<edge>>& G, int root=0) {
//         n = G.size();
//         log2_n = log2(n);
//         ancestor.resize(log2_n+1, vector<int>(n, -1));
//         depth.resize(n);
//         dfs(G, root, -1, 0);
//
//         for (int k = 0; k < log2_n; ++k) {
//             for (int v = 0; v < n; ++v) {
//                 if (ancestor[k][v] != -1) {
//                     ancestor[k+1][v] = ancestor[k][ancestor[k][v]];
//                 }
//             }
//         }
//     }
//
//     int operator()(int u, int v) {
//         if (depth[u] > depth[v]) swap(u, v);
//
//         // align the depth of u and v
//         for (int k = 0; k < log2_n; ++k) {
//             if ((depth[v] - depth[u]) >> k & 1) {
//                 v = ancestor[k][v];
//             }
//         }
//         if (u == v) return u;
//
//         // go back until u and v's ancestors do not match
//         for (int k = log2_n-1; k >= 0; --k) {
//             if (ancestor[k][u] != ancestor[k][v]) {
//                 u = ancestor[k][u];
//                 v = ancestor[k][v];
//             }
//         }
//         return ancestor[0][u];
//     }
// };

void dist_dfs(const auto& G, auto& dist, int v, int p, int d) {
    dist[v] = d;
    for (auto e : G[v]) {
        if (e.to == p) continue;
        dist_dfs(G, dist, e.to, v, d + e.cost);
    }
}

void tour_dfs(const auto& G, auto& tour, int v, int p) {
    for (auto e : G[v]) {
        if (e.to == p) continue;
        tour.push_back({e.color, e.cost});
        tour_dfs(G, tour, e.to, v);
        tour.push_back({e.color, -e.cost});
    }
}

void idx_dfs(const auto& G, auto& idx, int v, int p, int &i) {
    idx[v] = i;
    for (auto e : G[v]) {
        if (e.to == p) continue;
        ++i;
        idx_dfs(G, idx, e.to, v, i);
        ++i;
    }
}

signed main()
{
    int n, q; cin >> n >> q;
    vector<vector<edge>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a; --b; --c;
        G[a].push_back(edge{ b, c, d });
        G[b].push_back(edge{ a, c, d });
    }
    vector<int> x(q), y(q), u(q), v(q);
    for (int i = 0; i < q; ++i) {
        cin >> x[i] >> y[i] >> u[i] >> v[i];
        --x[i]; --u[i]; --v[i];
    }

    int root = 0;
    lca _lca(G, root);

    vector<int> dist(n);
    dist_dfs(G, dist, root, -1, 0);

    vector<pair<int,int>> tour;
    tour_dfs(G, tour, root, -1);

    vector<vector<pair<int,int>>> tour2(n);
    for (int i = 0; i < tour.size(); ++i) {
        int color = tour[i].fs;
        int cost = tour[i].sc;
        tour2[color].push_back({i, cost});
    }

    vector<vector<trio<int,int,int>>> sum(n);
    for (int i = 0; i < n; ++i) {
        sum[i].resize(tour2[i].size()+1);
        sum[i][0] = {-1, 0, 0};
        for (int j = 0; j < tour2[i].size(); ++j) {
            sum[i][j+1] = { tour2[i][j].fs, sum[i][j].sc + tour2[i][j].sc, sum[i][j].th + (tour2[i][j].sc > 0 ? 1 : -1) };
        }
    }

    vector<int> idx(n);
    int tmp_idx = -1;
    idx_dfs(G, idx, 0, -1, tmp_idx);

    for (int i = 0; i < q; ++i) {
        int ans = 0;
        int a = _lca.get(u[i], v[i]);
        ans += dist[u[i]] + dist[v[i]] - 2*dist[a];

        auto uit = prev(upper_bound(sum[x[i]].begin(), sum[x[i]].end(), make_trio( idx[u[i]], 0, 0 )));
        int su = uit->sc;
        int nu = uit->th;

        auto vit = prev(upper_bound(sum[x[i]].begin(), sum[x[i]].end(), make_trio( idx[v[i]], 0, 0 )));
        int sv = vit->sc;
        int nv = vit->th;

        auto ait = prev(upper_bound(sum[x[i]].begin(), sum[x[i]].end(), make_trio( idx[a], 0, 0 )));
        int sa = ait->sc;
        int na = ait->th;

        ans += (nu + nv - 2*na)*y[i];
        ans -= su + sv - 2*sa;

        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 36208