#include <bits/stdc++.h>

using namespace std;
const int N=100005;
const int sz=350;

int n;
vector<pair<int,int>> v[N];
vector<int> col(N),w(N);
int depth[N];
int dist[N];
int par[N][18];
int edge[N];
priority_queue<pair<int,int>> pq;
bool magic[N];
int magic_id[N];
int magic_cnt[sz][N];
int magic_len[sz][N];

void dfs1(int a,int p=-1)
{
    if(p!=-1)
    {
        dist[a]=dist[p]+w[edge[a]];
        depth[a]=depth[p]+1;
    }
    par[a][0]=p;
    for(int i=1;i<18;i++)
    {
        if(par[a][i-1]==-1) break;
        par[a][i]=par[par[a][i-1]][i-1];
    }
    for(pair<int,int> temp:v[a])
    {
        int to=temp.first;
        if(to==p) continue;
        edge[to]=temp.second;
        dfs1(to,a);
    }
    pq.push(make_pair(depth[a],a));
}

int lca(int a,int b)
{
    if(depth[a]>depth[b]) swap(a,b);
    for(int i=17;i>=0;i--)
    {
        if(par[b][i]!=-1&&depth[par[b][i]]>=depth[a])
        {
            b=par[b][i];
        }
    }
    if(a==b) return a;
    for(int i=17;i>=0;i--)
    {
        if(par[a][i]!=-1&&par[b][i]!=-1&&par[a][i]!=par[b][i])
        {
            a=par[a][i];
            b=par[b][i];
        }
    }
    return par[a][0];
}

void ini_magic()
{
    int idx=0;
    magic[1]=1;
    magic_id[1]=idx++;
    while(!pq.empty())
    {
        int a=pq.top().second;
        pq.pop();
        if(magic[a]) continue;
        bool found=0;
        for(int i=0;i<sz;i++)
        {
            a=par[a][0];
            if(magic[a])
            {
                found=1;
                break;
            }
        }
        if(found) continue;
        magic[a]=1;
        magic_id[a]=idx++;
    }
}

void set_magic()
{
    queue<int> q;
    vector<bool> vis(n+1,0);
    vis[1]=1;
    q.push(1);
    while(!q.empty())
    {
        int a=q.front();
        q.pop();
        for(pair<int,int> temp:v[a])
        {
            int to=temp.first;
            if(vis[to]) continue;
            vis[to]=1;
            q.push(to);
        }
        if(!magic[a]) continue;
        if(a==1) continue;
        int id=magic_id[a];
        magic_cnt[id][col[edge[a]]]++;
        magic_len[id][col[edge[a]]]+=w[edge[a]];
        int now=par[a][0];
        while(magic[now]==0)
        {
            magic_cnt[id][col[edge[now]]]++;
            magic_len[id][col[edge[now]]]+=w[edge[now]];
            now=par[now][0];
        }
        for(int i=1;i<=n-1;i++)
        {
            magic_cnt[id][i]+=magic_cnt[magic_id[now]][i];
            magic_len[id][i]+=magic_len[magic_id[now]][i];
        }
    }
}

int solve(int a,int x,int y) //x-col y-new_length
{
    int res=dist[a];
    int cnt=0,len=0;
    int now=a;
    while(magic[now]==0)
    {
        if(col[edge[now]]==x)
        {
            cnt++;
            len+=w[edge[now]];
        }
        now=par[now][0];
    }
    cnt+=magic_cnt[magic_id[now]][x];
    len+=magic_len[magic_id[now]][x];
    res-=len;
    res+=cnt*y;
    return res;
}

int main()
{
    for(int o=0;o<N;o++) for(int i=0;i<18;i++) par[o][i]=-1;
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n-1;i++)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        v[a].push_back(make_pair(b,i));
        v[b].push_back(make_pair(a,i));
        col[i]=c;
        w[i]=d;
    }
    dfs1(1);
    ini_magic();
    set_magic();
    while(q--)
    {
        int x,y,a,b;
        scanf("%d%d%d%d",&x,&y,&a,&b);
        printf("%d\n",solve(a,x,y)+solve(b,x,y)-2*solve(lca(a,b),x,y));
    }
    return 0;
}


Measured memory_bytes: 249332