#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<long long, long long>;

struct LCA {
  struct dfsdata {
    int v;
    int p;
    int d;
  };
  int root = 0, logv, maxv;
  vector<vector<int>> edge;
  vector<vector<int>> parent;
  vector<int> depth;
  LCA(int nmaxv = 1, int nlogv = 1) {
    maxv = nmaxv + 1;
    logv = nlogv + 1;
    edge.resize(maxv);
    parent.resize(logv);
    depth.resize(maxv);
    // reset();
  }
  void reset() {
    parent[0].resize(maxv);
    dfs();
    for(int i = 0; i < logv - 1; ++i) {
      parent[i + 1].resize(maxv);
      for(int j = 0; j < maxv; ++j) {
        if(parent[i][j] < 0)
          parent[i + 1][j] = -1;
        else
          parent[i + 1][j] = parent[i][parent[i][j]];
      }
    }
  }
  void dfs() {
    dfsdata now = {root, -1, 0}, nextdata;
    stack<dfsdata> st;
    st.push(now);
    while(st.size() > 0) {
      now = st.top();
      st.pop();
      parent[0][now.v] = now.p;
      depth[now.v] = now.d;
      for(int i = 0; i < edge[now.v].size(); ++i)
        if(edge[now.v][i] != now.p) {
          nextdata.d = now.d + 1;
          nextdata.p = now.v;
          nextdata.v = edge[now.v][i];
          st.push(nextdata);
        }
    }
  }
  int calc(int x, int y) {
    if(depth[x] > depth[y]) swap(x, y);
    for(int i = 0; i < logv; ++i)
      if(((depth[y] - depth[x]) >> i) & 1) y = parent[i][y];
    if(x == y) return x;
    for(int i = logv - 1; i >= 0; --i)
      if(parent[i][x] != parent[i][y]) {
        x = parent[i][x];
        y = parent[i][y];
      }
    return parent[0][y];
  }
  bool add(int x, int y) {
    edge[x].push_back(y);
    return 1;
  }
};

struct data {
  int to, d, c;
};
struct query {
  int num, x, y, u, v;
};
bool operator<(const query &l, const query &r) {
  if(l.x != r.x) return l.x < r.x;
  return l.num < r.num;
}

int n, q;
vector<int> dis, ans;
vector<vector<int>> colmemo;
vector<query> que;
vector<data> edge[100005];
vector<bool> reached;
// vnum,col,num,dis
map<P, P> mp;
map<int, P> dfsmp;
LCA lca;

void solve();
void calcdis();
void dfs(int now);

int main() {
  cin >> n >> q;
  lca = LCA(n, 32);
  for(int i = 0; i < n - 1; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    lca.add(--a, --b);
    lca.add(b, a);
    edge[a].push_back({b, d, c});
    edge[b].push_back({a, d, c});
  }
  que.resize(q);

  for(int i = 0; i < q; ++i) {
    int x, y, u, v;
    cin >> x >> y >> u >> v;
    --u, --v;
    que[i] = {i, x, y, u, v};
  }
  sort(que.begin(), que.end());
  solve();
  for(int i = 0; i < q; ++i) cout << ans[i] << endl;
  return 0;
}

void solve() {
  lca.reset();
  calcdis();
  colmemo.resize(n);
  for(int i = 0; i < q; ++i) {
    colmemo[que[i].u].push_back(que[i].x);
    colmemo[que[i].v].push_back(que[i].x);
    colmemo[lca.calc(que[i].u, que[i].v)].push_back(
        que[i].x);
  }
  reached.assign(n, 0);
  dfs(0);
  ans.assign(q, 0);
  for(int i = 0; i < q; ++i) {
    int now, par = lca.calc(que[i].u, que[i].v),
             col = que[i].x, u = que[i].u, v = que[i].v,
             y = que[i].y;
    now = dis[u] + dis[v] - 2 * dis[par];
    now -= mp[{u, col}].se + mp[{v, col}].se -
           2 * mp[{par, col}].se;
    now += (mp[{u, col}].fi + mp[{v, col}].fi -
            2 * mp[{par, col}].fi) *
           y;
    ans[que[i].num] = now;
  }
}

void calcdis() {
  dis.assign(n, -1);
  queue<int> qu;
  dis[0] = 0;
  qu.push(0);
  while(!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for(int i = 0; i < edge[now].size(); ++i)
      if(dis[edge[now][i].to] == -1) {
        dis[edge[now][i].to] = dis[now] + edge[now][i].d;
        qu.push(edge[now][i].to);
      }
  }
}

void dfs(int now) {
  reached[now] = 1;
  for(int i = 0; i < colmemo[now].size(); ++i)
    mp[{now, colmemo[now][i]}] = dfsmp[colmemo[now][i]];
  for(int i = 0; i < edge[now].size(); ++i)
    if(!reached[edge[now][i].to]) {
      ++dfsmp[edge[now][i].c].fi;
      dfsmp[edge[now][i].c].se += edge[now][i].d;
      dfs(edge[now][i].to);
      --dfsmp[edge[now][i].c].fi;
      dfsmp[edge[now][i].c].se -= edge[now][i].d;
    }
}

Measured memory_bytes: 61492