#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree {
  using T = struct { int sum, sz; };
  static T op(const T& x, const T& y) { return {x.sum + y.sum, x.sz + y.sz}; }
  static constexpr T e() { return {0, 0}; }
  using U = struct {
    int a, b;
    bool operator==(const auto& r) const { return a == r.a and b == r.b; }
  };
  static void ap(const U& f, T& x) { x.sum = f.a * x.sum + f.b * x.sz; }
  static void cp(const U& g, U& f) { f.a *= g.a, f.b = g.a * f.b + g.b; }
  static constexpr U id() { return {1, 0}; }

  const int n;
  V<T> t;
  V<U> u;
  SegmentTree(int n) : n(n), t(2 * n, e()), u(n, id()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  void push() { for (int i = 1; i < n; ++i) push(i); }
  void apply(const U& f, int i) {
    ap(f, t[i]);
    if (i < n) cp(f, u[i]);
  }
  void push(int i) {
    if (u[i] == id()) return;
    apply(u[i], 2 * i);
    apply(u[i], 2 * i + 1);
    u[i] = id();
  }
  void push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = l + n >> hl, ar = r - 1 + n >> hr;
      if (al < n) push(al);
      if (ar != al) push(ar);
    }
  }
  T acc(int l, int r) {
    push(l, r);
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  T get(int i) { return acc(i, i + 1); }
  void act(int l, int r, const U& f) {
    push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(f, i++);
      if (j & 1) apply(f, --j);
    }
    l = l + n >> __builtin_ctz(l + n);
    while (l >>= 1) t[l] = op(t[2 * l], t[2 * l + 1]);
    r = r + n >> __builtin_ctz(r + n);
    while (r >>= 1) t[r] = op(t[2 * r], t[2 * r + 1]);
  }
  void set(int i, const T& x) {
    push(i, i + 1);
    t[i += n] = x;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

// 部分木vは[in[v],out[v])に対応
// TODO: 非可換
struct HeavyLightDecomposition {
  const bool edge;
  const int n;
  VV<> g;
  V<> sz, par, in, out, anc, rev;
  HeavyLightDecomposition(VV<>& g, bool edge, int r = 0) :
    edge(edge), n(g.size()), g(g), sz(n), par(n), in(n), out(n), anc(n), rev(n) {
    dfs_sz(r, -1);
    anc[r] = r;
    dfs_hl(r);
  }
  void dfs_sz(int v, int p) {
    par[v] = p;
    for (auto&& w : g[v]) if (w == p) {
      swap(w, g[v].back());
      g[v].pop_back();
      break;
    }
    sz[v] = 1;
    for (auto&& w : g[v]) {
      dfs_sz(w, v);
      sz[v] += sz[w];
      if (sz[w] > sz[g[v][0]]) swap(w, g[v][0]);
    }
  }
  void dfs_hl(int v) {
    static int t = 0;
    in[v] = t++;
    rev[in[v]] = v;
    for (int w : g[v]) {
      anc[w] = w == g[v][0] ? anc[v] : w;
      dfs_hl(w);
    }
    out[v] = t;
  }
  int lca(int u, int v) const {
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) return u;
      v = par[anc[v]];
    }
  }
  auto acc(SegmentTree& st, int u, int v) const {
    auto res = st.e();
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) break;
      res = st.op(res, st.acc(in[anc[v]], in[v] + 1));
      v = par[anc[v]];
    }
    res = st.op(res, st.acc(in[u] + edge, in[v] + 1));
    return res;
  }
  void act(SegmentTree& st, int u, int v, const SegmentTree::U& f) const {
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) break;
      st.act(in[anc[v]], in[v] + 1, f);
      v = par[anc[v]];
    }
    st.act(in[u] + edge, in[v] + 1, f);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  VV<> g(n);
  V<> u(n - 1), v(n - 1), c(n - 1), d(n - 1);
  VV<> eid(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> u[i] >> v[i] >> c[i] >> d[i], --u[i], --v[i], --c[i];
    g[u[i]].push_back(v[i]);
    g[v[i]].push_back(u[i]);
    eid[c[i]].push_back(i);
  }
  HeavyLightDecomposition hld(g, true);
  SegmentTree st(n);
  for (int i = 0; i < n; ++i) st[i] = {0, 1};
  for (int i = 0; i < n - 1; ++i) {
    hld.act(st, u[i], v[i], {0, d[i]});
  }
  struct Q { int id, x, y, u, v; };
  VV<Q> qs(n - 1);
  for (int j = 0; j < q; ++j) {
    int x, y, u, v; cin >> x >> y >> u >> v, --x, --u, --v;
    qs[x].emplace_back(Q{j, x, y, u, v});
  }
  V<> d0(q), res(q);
  for (int k = 0; k < n - 1; ++k) {
    for (int i : eid[k]) {
      hld.act(st, u[i], v[i], {0, 0});
    }
    for (const auto& e : qs[k]) {
      d0[e.id] = hld.acc(st, e.u, e.v).sum;
    }
    for (int i : eid[k]) {
      hld.act(st, u[i], v[i], {0, 1});
    }
    for (const auto& e : qs[k]) {
      int d1 = hld.acc(st, e.u, e.v).sum;
      res[e.id] = d0[e.id] + e.y * (d1 - d0[e.id]);
    }
    for (int i : eid[k]) {
      hld.act(st, u[i], v[i], {0, d[i]});
    }
  }
  for (int e : res) cout << e << '\n';
}

Measured memory_bytes: 30608