#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
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;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) { init(n_, func_, unit_); }
  SegmentTree(vector<T> &v, Fn func_, T unit_) { init(v, func_, unit_); }

  void init(int n_, Fn func_, T unit_)
  {
    func = func_, unit = unit_;
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }

  void init(vector<T> &v, Fn func_, T unit_)
  {
    func = func_, unit = unit_;
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  T get(int k) { return dat[k + N - 1]; }

  T query(int a, int b, int k, int l, int r)
  {
    T vl = unit, vr = unit;
    for (a += (N - 1), b += (N - 1); a < b; a >>= 1, b >>= 1)
    {
      if ((a & 1) == 0)
        vl = func(vl, dat[a]);
      if ((b & 1) == 0)
        vr = func(vr, dat[--b]);
    }
    return func(vl, vr);
  }
  T query(int a, int b) { return query(a, b, 0, 0, N); }
};

template <typename T>
class HLD
{
public:
  vector<vector<int>> g;
  int n, root;
  vector<int> sz, par, in, out, head;
  bool calculated = false;
  void dfs_sz(int v, int p)
  { //最大サイズの部分木を最も左に配置　これによりオイラーツアーで訪れた順に番号を振るだけでよくなる　さらに部分木クエリにも対応できる
    sz[v] = 1, par[v] = p;
    for (auto &e : g[v])
    {
      if (e == p)
        swap(e, g[v].back());
      if (e == p)
        continue;
      dfs_sz(e, v);
      sz[v] += sz[e];
      if (sz[e] > sz[g[v][0]])
        swap(e, g[v][0]);
    }
  }
  void dfs_hld(int v, int p, int &t)
  { //inはオイラーツアーで訪れた順番　outはオイラーツアーで帰ってきた時の番号
    in[v] = t++;
    for (auto e : g[v])
    {
      if (e == p)
        continue;
      head[e] = (e == g[v][0] ? head[v] : e);
      dfs_hld(e, v, t);
    }
    out[v] = t;
  }

  void init()
  {
    dfs_sz(root, -1);
    int t = 0;
    head[root] = root;
    dfs_hld(root, -1, t);
  }

public:
  HLD(int _n, int _root = 0)
      : n(_n), g(_n), root(_root), sz(_n), par(_n, -1), head(_n, -1), in(_n), out(_n) {}
  void add_E(int a, int b)
  {
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  int get(int a) { return in[a]; } // オイラーツアーで振りなおした番号に変換
  int subtree_size(int a) { return sz[a]; }
  int get_ch(int a, int b) { return a == par[b] ? in[b] : in[a]; } // 辺の端点のうち下にある方をget

  int lca(int a, int b)
  {
    for (;; b = par[head[b]])
    {
      if (in[a] > in[b])
        swap(a, b);
      if (head[a] == head[b])
        return a;
    }
  }
  pii subtree_query(int a)
  {
    if (!calculated)
    {
      init();
      calculated = true;
    }
    return make_pair(in[a], out[a]);
  } //aを根とする部分木は[in[a],out[a])で表せる　よってセグ木などを利用可能
  vector<pii> path_query(int a, int b, bool isedge = false)
  { //aとbのパスを最大log(n)個の区間で表す　辺属性クエリの場合edgeをtrueにする
    //for(auto [l,r]:path_query(a,b))seg.update(l,r,hoge);　みたいに使う
    if (!calculated)
    {
      init();
      calculated = true;
    }
    vector<pii> ret;
    for (;; b = par[head[b]])
    {
      if (in[a] > in[b])
        swap(a, b);
      if (head[a] == head[b])
        break;
      ret.push_back({in[head[b]], in[b] + 1});
    }
    ret.push_back({in[a] + isedge, in[b] + 1});
    return ret;
  }
};

int main()
{
  init_main();

  int n, q;
  cin >> n >> q;

  struct edge_t
  {
    int a, b, d;
  };
  struct query_t
  {
    int x, y, u, v, i;
  };
  vector<edge_t> E[100010];
  HLD<int> hld(n);
  repi(i, n - 1)
  {
    int t1, t2, t3, t4;
    cin >> t1 >> t2 >> t3 >> t4;
    t1--, t2--, t3--;
    E[t3].push_back({t1, t2, t4});
    hld.add_E(t1, t2);
  }
  hld.init();
  vector<query_t> Q(q);
  repi(i, q)
  {
    int t1, t2, t3, t4;
    cin >> t1 >> t2 >> t3 >> t4;
    t1--, t3--, t4--;
    Q[i] = query_t{t1, t2, t3, t4, i};
  }

  auto comp_Q = [&](query_t &q1, query_t &q2) {
    return q1.x < q2.x;
  };
  sort(all(Q), comp_Q);

  vector<int> temp(n);
  repi(color, 100000)
  {
    for (auto e : E[color])
      temp[hld.get_ch(e.a, e.b)] = e.d;
  }
  SegmentTree<int> sg1(temp, plus<int>(), 0), sg2(n, plus<int>(), 0);
  int qi = 0;
  int ans[100000];
  repi(color, n)
  {
    // 辺を変更
    for (auto e : E[color])
    {
      int index = hld.get_ch(e.a, e.b);
      sg1.update(index, 0);
      sg2.update(index, 1);
    }

    // クエリを処理
    while (qi < q && Q[qi].x == color)
    {
      vector<pii> vp = hld.path_query(Q[qi].u, Q[qi].v, true);
      int sum = 0;
      int l, r;
      for (auto p : vp)
      {
        tie(l, r) = p;
        sum += sg1.query(l, r) + sg2.query(l, r) * Q[qi].y;
      }
      ans[Q[qi].i] = sum;
      qi++;
    }

    // 辺の変更を取り消し
    for (auto e : E[color])
    {
      int index = hld.get_ch(e.a, e.b);
      sg1.update(index, e.d);
      sg2.update(index, 0);
    }
  }

  repi(i, q) cout << ans[i] << "\n";
  return 0;
}

Measured memory_bytes: 20920