#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


template<typename T>
struct RMQ {
  vector<T> v;
  VV st; // sparse table
  int op(int a, int b) { return v[a]==v[b] ? min(a, b) : (v[a]<v[b] ? a : b); } 
  void init(const vector<T> &_v) {
    v = _v;
    int n = v.size();
    st = {V(n)}; iota(all(st[0]), 0);
    for (int j=1; 1<<j <= n; ++j) {
      int m = n-(1<<j)+1;
      st.push_back(V(m));
      rep(i, m) st[j][i] = op(st[j-1][i], st[j-1][i+(1<<(j-1))]);
    }
  }
  int index(int l, int r) { int d = 31-__builtin_clz(r-l); return op(st[d][l], st[d][r-(1<<d)]); }
  T query(int l, int r) { return v[index(l, r)]; }
};


V c, dst;
V dall(1);
V tl, tour, dep;
vector<vector<P>> G;
RMQ<int> R;
int tt = 0;

VV cd, ct;

void dfs(int &t, int u, int p=-1, int d=0) {
  tour[t] = u;
  dep[t] = d;
  tl[u] = t++;
  for (auto &[i, v] : G[u]) if (v != p) {
    cd[c[i]].push_back(dst[i]);
    dall.push_back(dst[i]);
    ct[c[i]].push_back(tt++);
    dfs(t, v, u, d+1);
    cd[c[i]].push_back(-dst[i]);
    dall.push_back(-dst[i]);
    ct[c[i]].push_back(tt++);
  }
  tour[t] = p;
  dep[t] = d-1;
  ++t;
}

int lca(int u, int v) {
  return tour[R.index(min(tl[u], tl[v]), max(tl[u], tl[v]))];
}


int main() {
  int n, q; cin >> n >> q;
  c.assign(n, 0);
  dst.assign(n, 0);
  tl.assign(n, 0);
  tour.assign(2*n, 0);
  dep.assign(2*n, 0);
  G.assign(n, vector<P>());
  cd.assign(n, V(1));
  ct.assign(n, V());

  rep(i, n-1) {
    int a, b;
    cin >> a >> b >> c[i] >> dst[i];
    --a, --b;
    G[a].emplace_back(i, b);
    G[b].emplace_back(i, a);
  }

  int t = 0;
  dfs(t, 0);
  R.init(dep);

  auto cE = cd;
  for (auto &v : cE) for (auto &e : v) e = clamp(e, -1, 1);
  for (auto &v : cd) rep(i, v.size()-1) v[i+1] += v[i];
  for (auto &v : cE) rep(i, v.size()-1) v[i+1] += v[i];
  rep(i, dall.size()-1) dall[i+1] += dall[i];

  auto f = [&] (int x, int y, int u, int v) {
    int &i = tl[u];
    int &j = tl[v];
    int ix = lower_bound(all(ct[x]), i) - ct[x].begin();
    int jx = lower_bound(all(ct[x]), j) - ct[x].begin();

    int res = dall[j] - dall[i];
    res -= cd[x][jx] - cd[x][ix];
    res += (cE[x][jx] - cE[x][ix]) * y;
    return res;
  };

  rep(_, q) {
    int x, y, u, v; cin >> x >> y >> u >> v;
    --u, --v;
    int w = lca(u, v);

    int ans = 0;
    ans += f(x, y, w, u);
    ans += f(x, y, w, v);
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 48288