#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

template <typename T, typename F>
class SegTree{
  int n; T uni; F f;
  vector<T> dat;
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n,uni);
  }
  void set(int k, const T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int k, T x) {
    k += n;
    dat[k] = x;
    while(k >>= 1){
      dat[k] = f(dat[2*k],dat[2*k+1]);
    }
  }
  T query(int a, int b) {
    T l = uni, r = uni;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) l = f(l,dat[a++]);
      if(b & 1) r = f(dat[--b],r);
    }
    return f(l,r);
  }
};

struct HLD {
  int n;
  vector<vector<int>>& g;
  vector<int> vid, head, sz, par;

  HLD(vector<vector<int>>& g): g(g), n(g.size()), vid(n,-1), head(n), sz(n,1), par(n) {}

  void dfs1(int v, int p) {
    if(g[v].size() && g[v][0] == p) swap(g[v][0],g[v].back());
    for(auto &to : g[v]) {
      if(to == p) continue;
      dfs1(to, v);
      sz[v] += sz[to];
      if(sz[to] > sz[g[v][0]]) swap(to,g[v][0]);
    }
  }

  void dfs2(int v, int p, int &k) {
    par[v] = p; vid[v] = k++;
    for(auto to : g[v]) {
      if(to == p) continue;
      head[to] = (to == g[v][0] ? head[v] : to);
      dfs2(to,v,k);
    }
  }

  void build(vector<int> rs = vector<int>(1,0)) {
    int k = 0;
    for(int r : rs) {
      dfs1(r,-1);
      head[r] = r;
      dfs2(r,-1,k);
    }
  }

  void for_each_vertex(int u, int v, const function<void(int,int)>& f) {
    while(true) {
      if(vid[u] > vid[v]) swap(u,v);
      f(max(vid[head[v]],vid[u]),vid[v]);
      if(head[u] != head[v]) v = par[head[v]];
      else break;
    }
  }

  void for_each_edge(int u, int v, const function<void(int,int)>& f) {
    while(true) {
      if(vid[u] > vid[v]) swap(u,v);
      if(head[u] != head[v]) {
        f(vid[head[v]],vid[v]); 
        v = par[head[v]];
      } else {
        if(u != v) f(vid[u]+1,vid[v]);
        break;
      }
    }
  }

  int lca(int u, int v) {
    while(true) {
      if(vid[u] > vid[v]) swap(u,v);
      if(head[u] == head[v]) return u;
      v = par[head[v]];
    }
  }
};

struct query {
  int id, u, v; ll w;
};

struct edge {
  int u, v; ll w;
};

int main(){
  int n, q;
  cin >> n >> q;
  vector<vector<int>> g(n);
  vector<vector<edge>> ce(n);
  vector<vector<query>> cq(n);
  vector<ll> ans(q);
  rep(i,n-1) {
    int a, b, c; ll d;
    cin >> a >> b >> c >> d;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
    ce[c].push_back(edge{a,b,d});
  }
  HLD hld(g);
  hld.build();
  rep(i,q) {
    int x; ll y; int u, v;
    cin >> x >> y >> u >> v;
    u--; v--;
    cq[x].push_back(query{i,u,v,y});
  }
  auto f = [](ll a, ll b){return a + b;};
  SegTree<ll,decltype(f)> stc(n,f,0);
  SegTree<ll,decltype(f)> stw(n,f,0);
  rep(i,n) {
    for(auto e : ce[i]) {
      if(hld.par[e.u] == e.v) stw.update(hld.vid[e.u],e.w);
      else stw.update(hld.vid[e.v],e.w);
    }
  }
  rep(i,n) {
    for(auto e : ce[i]) {
      if(hld.par[e.u] == e.v) {
        stw.update(hld.vid[e.u],0);
        stc.update(hld.vid[e.u],1);
      } else {
        stw.update(hld.vid[e.v],0);
        stc.update(hld.vid[e.v],1);
      }
    }
    for(auto task : cq[i]) {
      ll val = 0;
      hld.for_each_edge(task.u,task.v,[&](int l, int r){val += stc.query(l,r+1);});
      val *= task.w;
      hld.for_each_edge(task.u,task.v,[&](int l, int r){val += stw.query(l,r+1);});
      ans[task.id] = val;
    }
    for(auto e : ce[i]) {
      if(hld.par[e.u] == e.v) {
        stw.update(hld.vid[e.u],e.w);
        stc.update(hld.vid[e.u],0);
      } else {
        stw.update(hld.vid[e.v],e.w);
        stc.update(hld.vid[e.v],0);
      }
    }
  }
  for(auto v : ans) cout << v << endl;
  return 0;
}

Measured memory_bytes: 30608