#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(ll i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;
const ll MAX_LOG_V = 40;
struct edge{
    ll from,to,cost,color;
};
vector<edge> G[100010];
ll par[MAX_LOG_V][100010],depth[100010],dist[100010];
vector<pair<ll,ll> > tour(200020);

ll used[200020];
ll num[100010];
ll id = 0;
vector<pair<ll,ll> > sum[100010];
vector<pair<ll,ll> > number[100010];
vector<pair<ll,ll> > tour_data[100010];
//LCA 
void dfs(ll v,ll p,ll dpt,ll dis){
    par[0][v] = p,depth[v] = dpt,dist[v] = dis;
    for(auto i : G[v]){
        if(i.to != p)dfs(i.to,v,dpt+1,dis+i.cost);
    }
}
void init(ll V){
    dfs(0,-1,0,0);
    for(ll k = 0;k+1 < MAX_LOG_V - 1;k++){
        for(ll v = 0;v < V;v++){
            if(par[k][v] < 0)par[k+1][v] = -1;
            else par[k+1][v] = par[k][par[k][v]];
        }
    }
}
ll lca(ll u,ll v){
    if(depth[u] > depth[v])swap(u,v);
    for(ll k = 0;k < MAX_LOG_V;k++){
        if((depth[v] - depth[u]) >> k & 1){
            v = par[k][v];
        }
    }
    if(u == v)return u;
    for(ll k = MAX_LOG_V-1;k >= 0;k--){
        if(par[k][v] != par[k][u]){
            u = par[k][u];
            v = par[k][v];
        }
    }
    return par[0][u];
}


//Euler-tour
void dfs2(edge& e,ll& id){
    tour[id++] = make_pair(e.cost,e.color);
    num[e.to] = id;
    if(sum[e.color].size() == 1){
        sum[e.color].push_back(make_pair(id,e.cost));
        number[e.color].push_back(make_pair(id,1));
    }else{
        sum[e.color].push_back(make_pair(id,sum[e.color].back().second + e.cost));
        number[e.color].push_back(make_pair(id,number[e.color].back().second + 1));
    }
    used[e.from]++;
    for(edge& i : G[e.to]){
        if(!used[i.to]){
            dfs2(i,id);
        }
    }
    tour[id++] = make_pair(-e.cost,e.color);
    if(sum[e.color].size() == 1){
        sum[e.color].push_back(make_pair(id,-e.cost));
        number[e.color].push_back(make_pair(id,-1));
    }else{
        sum[e.color].push_back(make_pair(id,sum[e.color].back().second - e.cost));
        number[e.color].push_back(make_pair(id,number[e.color].back().second - 1));
    }
}
ll get_color(ll x){
    return tour[num[x]].second;
}
ll func(ll color,ll new_d,ll v){
    
    ll l = 0,r = sum[color].size();
    if(r == 1){
        return dist[v];
    }
    while(l+1 != r){
        ll m = (l + r)/2;
//      cout << m << '\n';
        if(sum[color][m].first <= num[v])l = m;
        else r = m;
    }

//    assert(l < sum[color].size());
    ll N = number[color][l].second;
    ll S = sum[color][l].second;

    //cout << color << ',' << v << ',' << S << ',' << N << '\n';
    //cout << v  << ',' << num[v] << ',' << dist[v] << ',' << S << ',' << N << '\n';
    return dist[v] - S + N*new_d;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,q;cin >> n >> q;
    for(ll i = 0;i < n-1;i++){
        ll a,b,c,d;cin >> a >> b >> c >> d;
        a--,b--;
        edge e1,e2;
        e1.from = a,e1.to = b,e1.cost = d,e1.color = c;
        e2.from = b,e2.to = a,e2.cost = d,e2.color = c;
        G[a].push_back(e1);
        G[b].push_back(e2);
    }
    init(n);
    //making Euler-tour
    for(ll i = 0;i < n;i++){
        sum[i].push_back(make_pair(0,0));
        number[i].push_back(make_pair(0,0));
    }
    for(edge& e : G[0])dfs2(e,id);
    //for(ll i = 0;i < id;i++)cout << tour[i].first << ' ' << tour[i].second << '\n';
    //for(ll i = 0;i < n;i++){
    //    cout << i << ":";
    //    for(auto j : sum[i])cout << "(" << j.first << ',' << j.second << ")";
    //    cout << '\n';
    //}
    for(ll t = 0;t < q;t++){
        ll x,y,u,v;cin >> x >> y >> u >> v;
        u--,v--;
//      cout << sum[x].size() << '\n';
        cout << func(x,y,u) + func(x,y,v) - 2*func(x,y,lca(u,v)) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 77152