#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

struct HLD {
  vector<int> label, parent, head;

  HLD(const vector<vector<int>> &g) : label(g.size()), parent(g.size()), head(g.size()) {
    const int n = g.size();
    vector<int> size(n, 1);
    auto dfs = [&](auto dfs, int u, int p) -> void {
      for (int v : g[u]) if (v != p) {
        dfs(dfs, v, u);
        size[u] += size[v];
      }
    };
    dfs(dfs, 0, -1);
    int k = 0;
    auto dfs2 = [&](auto dfs, int u, int p, int h) -> void {
      label[u] = k++;
      head[u] = h;
      parent[u] = p;
      for (int v : g[u]) if (v != p && size[v] * 2 >  size[u]) dfs(dfs, v, u, h);
      for (int v : g[u]) if (v != p && size[v] * 2 <= size[u]) dfs(dfs, v, u, v);
    };
    dfs2(dfs2, 0, -1, 0);
  }

  int lca(int u, int v) {
    for (;;) {
      if (label[u] > label[v]) swap(u, v);
      if (head[u] == head[v]) return u;
      v = parent[head[v]];
    }
  }

  template<class F> void each(int u, int v, F f) {
    for (;;) {
      if (label[u] > label[v]) swap(u, v);
      if (head[u] == head[v]) {
        f(label[u], label[v]);
        return;
      }
      f(label[head[v]], label[v]);
      v = parent[head[v]];
    }
  }

  template<class F> void each_edge(int u, int v, F f) {
    for (;;) {
      if (label[u] > label[v]) swap(u, v);
      if (head[u] == head[v]) {
        if (u != v) f(label[u] + 1, label[v]);
        return;
      }
      f(label[head[v]], label[v]);
      v = parent[head[v]];
    }
  }

  int operator[](int u) {
    return label[u];
  };
};

struct RMQ {
  int N;
  vector<int> dat;

  RMQ(int n) {
    N = 1;
    while (N < n) N *= 2;
    dat.resize(N * 2);
  }

  void update(int k, int v) {
    k += N;
    dat[k] = v;
    while (k > 1) {
      k >>= 1;
      dat[k] = dat[k * 2] + dat[k * 2 + 1];
    }
  }

  int query(int l, int r) {
    l += N;
    r += N;
    int res = 0;
    while (l <= r) {
      if ((l & 1) == 1) res += dat[l++];
      if ((r & 1) == 0) res += dat[r--];
      l >>= 1;
      r >>= 1;
    }
    return res;
  }
};


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<vector<int>> g(n);
  struct edge {
    int v, w, c;
  };
  vector<vector<edge>> g2(n);
  rep(i, n-1) {
    int u, v, c, w;
    cin >> u >> v >> c >> w;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
    g2[u].push_back((edge){v, w, c});
    g2[v].push_back((edge){u, w, c});
  }
  HLD hld(g);
  vector<int> ws(n);
  vector<int> cs(n);
  map<int, vector<int>> mp2;
  auto dfs = [&](auto dfs, int u, int p) -> void {
    for (edge e : g2[u]) if (e.v != p) {
      ws[e.v] = e.w;
      cs[e.v] = e.c;
      dfs(dfs, e.v, u);
    }
  };
  dfs(dfs, 0, -1);
  for (int i = 1; i < n; i++) {
    mp2[cs[i]].push_back(i);
  }
  RMQ rmq(n);
  for (int i = 1; i < n; i++) {
    rmq.update(hld[i], ws[i]);
  }
  vector<ll> ans(q);
  vector<int> xs(q), ys(q), us(q), vs(q);
  rep(i, q) {
    cin >> xs[i] >> ys[i] >> us[i] >> vs[i];
    us[i]--;
    vs[i]--;
    hld.each_edge(us[i], vs[i], [&](int l, int r) {
      ans[i] += rmq.query(l, r);
    });
  }
  map<int, vector<int>> mp;
  rep(i, q) {
    mp[xs[i]].push_back(i);
  } 
  RMQ rmq2(n); 
  RMQ rmq3(n);
  for (auto kv : mp) {
    for (int i : mp2[kv.first]) {
      rmq2.update(hld[i], ws[i]);
      rmq3.update(hld[i], 1);
    }
    for (int i : kv.second) {
      hld.each_edge(us[i], vs[i], [&](int l, int r) {
        ans[i] -= rmq2.query(l, r);
        ans[i] += rmq3.query(l, r) * ys[i];
      });
    }
    for (int i : mp2[kv.first]) {
      rmq2.update(hld[i], 0);
      rmq3.update(hld[i], 0);
    }
  }
  rep(i, q) {
    cout << ans[i] << '\n';
  }
}

Measured memory_bytes: 58232