#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

const int N = 1e5 + 10;
const int M = sqrt(N);
const int L = 17; //2^L >= N
int n, q;
int parent[N][L];
int depth[N];
bool special[N];
int* cnts_color[N];
int* sums_color[N];

vector<unordered_map<int, pii>> edges;
void dfs(int u, int p){
   depth[u] = 1 + depth[p];
   parent[u][0] = p;
   for(int i=1; i<L; i++)
       parent[u][i] = parent[parent[u][i-1]][i-1];
   for(auto it : edges[u]) if (it.first != p){
        dfs(it.first, u);
   }
}

int cnt_color[N];
int sum_color[N];
int dists[N];
void dfs2(int u, int p){
    if (special[u]){
        cnts_color[u] = new int[N];
        memcpy(cnts_color[u], cnt_color, sizeof(cnt_color));
        sums_color[u] = new int[N];
        memcpy(sums_color[u], sum_color, sizeof(sum_color));
    }
    for(auto it : edges[u]) if (it.first != p){
        cnt_color[it.second.first]++;
        sum_color[it.second.first] += it.second.second;
        dists[it.first] = dists[u] + it.second.second;
        dfs2(it.first, u);
        cnt_color[it.second.first]--;
        sum_color[it.second.first] -= it.second.second;
    }
}

int lca(int u, int v){
    if (depth[u] < depth[v])
        swap(u, v);
    if (depth[u] > depth[v]){
        FORI(i, L){
            int pu = parent[u][i];
            if (depth[pu] >= depth[v])
                u = pu;
        }
    }
    if (u==v)
        return u;
    if (depth[u]==depth[v]){
        FORI(i, L){
            int pu = parent[u][i];
            int pv = parent[v][i];
            if (pu != pv) {
                u = pu;
                v = pv;
            }
        }
    }
    return parent[u][0];
}

int find_cnt(int u, int color){
    int rez = 0;
    while(!special[u]) {
        int pu = parent[u][0];
        rez += edges[u][pu].first == color;
        u = pu;
    }
    return rez + cnts_color[u][color];
}

int find_sum(int u, int color){
    int rez = 0;
    while(!special[u]) {
        int pu = parent[u][0];
        rez += (edges[u][pu].first == color)* edges[u][pu].second;
        u = pu;
    }
    return rez + sums_color[u][color];
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    cin >> n >> q;
    edges.resize(n+1);
    FOR(i, n-1){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        edges[a][b] = {c, d};
        edges[b][a] = {c, d};
    }
    dfs(1, 1);

    FORI(i, N){
        bool ok = false;
        int u = i;
        FOR(l, M){
            if (u==1)
                break;
            if (special[u]){
                ok = true;
                break;
            }
            u = parent[u][0];
        }
        if (!ok){
            special[u] = true;
        }
    }

    dfs2(1, 1);

    FOR(i, q){
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        int t = lca(u, v);
        ll dist = 1ll*dists[u] + dists[v] - 2*dists[t];
        ll cnt = 1ll*find_cnt(u, x) + find_cnt(v, x) - 2*find_cnt(t, x);
        ll sum = 1ll*find_sum(u, x) + find_sum(v, x) - 2*find_sum(t, x);
        cout << dist - sum + cnt * y << '\n';
    }

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 999168