#include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 100016

int tcur = 0;
int c[N], d[N];
int dep[N], pe[N], dist[N];
int p[N][20];
map<int, int> mpc[2*N], mps[2*N];
int tl[N], tr[N];
int tour[2*N];
vpii adj[N];

void dfs(int u)
{
    for (int i = 0; p[u][i]; ++i) p[u][i+1] = p[p[u][i]][i];
    tl[u] = ++tcur;
    tour[tl[u]] = pe[u];
    for (const pii &ep : adj[u]) {
        int v = ep.fir, i = ep.sec;
        ctif(v == p[u][0]);
        p[v][0] = u;
        pe[v] = i;
        dep[v] = dep[u]+1;
        dist[v] = dist[u]+d[i];
        dfs(v);
    }
    tr[u] = ++tcur;
    tour[tr[u]] = -pe[u];
}

void upd(int i, int j, int n)
{
    retif(!j);
    int w = 1;
    if (j < 0) j = -j, w = -1;
    for (; i <= n; i += i&-i) {
        mpc[i][c[j]] += w;
        mps[i][c[j]] += w*d[j];
    }
}

pii get(int i, int c)
{
    int cnt = 0, sum = 0;
    for (; i; i -= i&-i) {
        if (mpc[i].count(c)) {
            cnt += mpc[i][c];
            sum += mps[i][c];
        }
    }
    return mkp(cnt, sum);
}

int lca(int x, int y)
{
    if (dep[x] > dep[y]) swap(x, y);
    for (int dd = dep[y]-dep[x], i = 0; dd; dd >>= 1, ++i) {
        if (dd&1) y = p[y][i];
    }
    retif(x == y) x;
    for (int i = 16; i >= 0; --i) {
        int px = p[x][i], py = p[y][i];
        if (px != py) {
            x = px;
            y = py;
        }
    }
    return p[x][0];
}

int main()
{
    canhazfast();

    int n, q;

    cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v >> c[i] >> d[i];
        adj[u].empb(v, i);
        adj[v].empb(u, i);
    }
    dfs(1);
    for (int i = 1; i <= 2*n; ++i) {
        if (tour[i]) upd(i, tour[i], 2*n);
    }
    for (; q; --q) {
        int x, y, u, v;
        int cx = 0, sx = 0;
        pii tmp;
        cin >> x >> y >> u >> v;
        int w = lca(u, v);
        int cur = dist[u]+dist[v]-2*dist[w];
        tmp = get(tl[u], x); cx += tmp.fir; sx += tmp.sec;
        tmp = get(tl[v], x); cx += tmp.fir; sx += tmp.sec;
        tmp = get(tl[w], x); cx -= 2*tmp.fir; sx -= 2*tmp.sec;
        int ans = cur-sx+cx*y;
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 132352