#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
using namespace std;

#include <sys/mman.h>
static char *_in_buf = 
(char*)mmap(NULL, 1 << 26, PROT_READ, MAP_PRIVATE, fileno(stdin), 0);
inline int read() {
  int p = 0, v = 0;
  while (*_in_buf < 48) (*_in_buf ++ == 45) && (v = 1);
  while (*_in_buf > 47 && *_in_buf < 58) p = p * 10 + *_in_buf ++ - 48;
  return v ? -p : p;
}

static char out_buf[100000];
static char *outf = out_buf;
inline void flush() {
  if (outf != out_buf)
    fwrite(out_buf, outf - out_buf, 1, stdout), outf = out_buf;
}
inline void Putchar(char x) {
  *outf ++ = x;
  (outf == out_buf + 100000) && (flush(), 0);
}

int n, q, ans[100005], dis[100005];
vector <tuple <int, int, int> > g[100005];

int par[100005], sz[100005];
int son[100005], dep[100005];
int ind[100005], top[100005], indx;
void dfs1(int u, int parent, int depth) {
  dep[u] = depth, par[u] = parent, sz[u] = 1;
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0> (g[u][i]);
    if (v == parent) continue;
    dfs1(v, u, depth + 1), sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int topv) {
  top[u] = topv, ind[u] = ++ indx;
  if (son[u]) dfs2(son[u], topv);
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0> (g[u][i]);
    if (v == par[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
inline int get_lca(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]])
      swap(u, v);
    u = par[top[u]];
  }
  if (dep[u] < dep[v]) return u;
  return v;
}

int dist[100005];
void dfs3(int u, int parent) {
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0>(g[u][i]), w = get <2>(g[u][i]);
    if (v == parent) continue;
    dist[v] = dist[u] + w, dfs3(v, u);
  }
}

vector <tuple <int, int, int> > qry[100005];
int d[100005], cnt[100005];
void dfs4(int u, int parent) {
  for (int i = 0; i < (int)g[u].size(); ++ i) {
    int v = get <0>(g[u][i]), c = get <1> (g[u][i]), w = get <2>(g[u][i]);
    if (v == parent) continue;
    d[c] += w, cnt[c] ++;
    dfs4(v, u);
    d[c] -= w, cnt[c] --;
  }
  for (int i = 0; i < (int)qry[u].size(); ++ i) {
    int id = get <0>(qry[u][i]), c = get <1>(qry[u][i]);
    int t = get <2>(qry[u][i]), nowd = dis[id];
    int x = d[c], y = nowd * cnt[c];
    ans[id] += (y - x) * t;
  }
}

int main() {
  n = read(), q = read();
  for (int i = 1; i < n; ++ i) {
    int u = read(), v = read();
    int c = read(), d = read();
    g[u].emplace_back(v, c, d);
    g[v].emplace_back(u, c, d);
  }
  dfs1(1, 0, 1);
  dfs2(1, 1);
  dfs3(1, 0);
  for (int i = 1; i <= q; ++ i) {
    int c = read(); dis[i] = read();
    int u = read(), v = read();
    int lca = get_lca(u, v);
    ans[i] = dist[u] + dist[v] - 2 * dist[lca];
    qry[u].emplace_back(i, c, 1);
    qry[v].emplace_back(i, c, 1);
    qry[lca].emplace_back(i, c, -2);
  }
  dfs4(1, 0);
  for (int i = 1; i <= q; ++ i) {
    register char stk[20], top = 0;
    while (ans[i]) stk[top ++] = ans[i] % 10, ans[i] /= 10;
    while (top --) Putchar(stk[top] + 48);
    Putchar('\n');
  }
  flush();
  return 0;
}

Measured memory_bytes: 38200