#include "infection.h"
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
#define fr(i,ii,iii) for(int i=ii;i<iii;i++)
using namespace std;
const int N=150005,M=21;
vi v[N];
int tt,in[N],out[N],h[N],n,m;
int par[N][M];
void dfs(int st,int p,int x){
	par[st][0]=p;
	h[st]=x;
	tt++;
	in[st]=tt;
	for(auto i:v[st]){
		if(i!=p)dfs(i,st,x+1);
	}
	out[st]=tt;
}
bool check(int a,int b){
	if(in[a]<=in[b] and out[a]>=out[b])return 1;
	return 0;
}
std::vector<int> solve(
    std::vector<std::pair<int, int>> R,
    std::vector<long long> D,
    std::vector<int> S,
    std::vector<int> T,
    std::vector<bool> I
) {
	n=R.size()+1;m=D.size();
	for(auto i:R){
		v[i.ff].pb(i.ss);
		v[i.ss].pb(i.ff);
	}
	fr(j,0,M){
		fr(i,0,n){
			par[i][j]=-1;
		}
	}
	dfs(0,-1,0);
	fr(i,0,n){
		//cout<<in[i]<<" "<<out[i]<<"\n";
		//cout<<par[i][0]<<" ";
		//cout<<h[i]<<" ";
	}//cout<<"\n";
	fr(j,1,M){
		fr(i,0,n){
			if(par[i][j-1]==-1)par[i][j]=-1;
			else par[i][j]=par[par[i][j-1]][j-1];
		}
	}
	//fr(j,0,M)cout<<par[10][j]<<" ";cout<<"\n";
	vi ans(m);
	fr(pp,0,m){
		if(I[pp]==0){
			ans[pp]=0;
			continue;
		}
		int a,a1,na,b;
		a=S[pp];b=T[pp];
		if(h[a]<h[b])swap(a,b);
		//cout<<a<<" "<<b<<"\n";
		a1=a;
		for(int j=M-1;j>=0;j--){
			//cout<<a<<" ";
			na=par[a][j];
			if(na==-1 or check(na,b))continue;
			a=na;
			//cout<<a<<" ";
		}//cout<<"\n";
		a=par[a][0];//cout<<a<<"\n";
		int s=h[a1]+h[b]-2*h[a];
		ans[pp]=s+1;
	}
	return ans;
}

signed main() {
    int n, m;

    std::cin >> n;
    std::cin >> m;

    std::vector<std::pair<int, int>> edges = {};
    std::vector<long long> day;
    std::vector<int> start;
    std::vector<int> target;
    std::vector<bool> infected;

    for (int i = 0; i < n - 1; i++) {
        int u, v;
        std::cin >> u >> v;
        edges.emplace_back(u, v);
    }

    for (int i = 0; i < m; i++) {
        long long _d, _s, _t, _i;
        std::cin >> _d >> _s >> _t >> _i;
        day.push_back(_d);
        start.push_back(_s);
        target.push_back(_t);
        infected.push_back(_i);
    }

    const auto ans = solve(edges, day, start, target, infected);
    for (const auto it : ans) {
        std::cout << it << std::endl;
    }

    return 0;
}

/*
9 5
0 1
1 2
2 3
3 4
4 5
3 6
6 7
6 8
0 0 5 1
0 5 7 1
0 5 7 1
0 7 8 1
0 0 1 1

12 1
0 1
0 2
1 3
3 4
4 5
2 6
2 7
7 8
8 9
8 10
6 11
0 10 9 1
*/