#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define endl "\n"
int t,A,k;

void solve(){

    //B>A이면 B==A여도 똑같은듯

    int ans1 = (int)abs(k-A);
    int ans2 = (int)1e6;

    //두번째 경우는 무조건 A>k일때네
    if(A>k){
        if(A%2==k%2){
            ans2=1;
        }else{
            ans2=0;
        }
    }

    cout << min(ans2,ans1) << endl;

}

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    //OB와 AB사이의 거리가 같은 B를 찾으려고한다.
    //B를 못찾을때 A를 증감시켜볼수있다.
    cin >> t;
    while(t--){
        cin >> A >> k;
        //AB,OB거리 차이의 절대값이 k인걸 찾으려면 몇 step?
        //A와 0위치를 준다.
        solve();

    }

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        bool flag=false;
        long long int n,k;
        cin>>n>>k;
        long long int low=1;
        long long int high=n;
        while(low<=high){
           long long int mid=(low+high)/2;
            if(abs((n-mid)-mid)==k){
                flag=true;
                break;
            }
            else if((abs((n-mid)-mid))>k){
                high=mid-1;
            }
            else{
                low=mid+1;
            }
        }
        if(flag){
            cout<<0<<endl;
        }
        else{
            cout<<abs(n-k)<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        bool flag=false;
        long long int n,k;
        cin>>n>>k;
        long long int low=0;
        long long int high=n;
        while(low<=high){
            long long int mid=(low+high)/2;
            if(abs((n-mid)-mid)==k){
                flag=true;
                break;
            }
            else if((abs((n-mid)-mid))>k){
                high=mid-1;
            }
            else{
                low=mid+1;
            }
        }
        if(flag){
            cout<<0<<endl;
        }
        else{
            cout<<abs(n-k)<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,k;
        cin>>n>>k;
        if(n==1 && k==0){
            cout<<1<<endl;
            continue;
        }
        if(n>=k){
            cout<<0<<endl;
        }
        else{
            cout<<max(n,k)-min(n,k)<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        bool flag=false;
        long long int n,k;
        cin>>n>>k;
        long long int low=0;
        long long int high=1e6;
        while(low<=high){
           long long int mid=(low+high)/2;
           long long int check= abs((mid)-abs(mid-n));
            if(check==k){
                flag=true;
                break;
            }
            else if(check>k){
                high=mid-1;
            }
            else{
                low=mid+1;
            }
        }
        if(flag){
            cout<<0<<endl;
        }
        else{
            cout<<abs(n-k)<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        bool flag=false;
        long long int n,k;
        cin>>n>>k;
        long long int low=0;
        long long int high=n;
        while(low<=high){
            long long int mid=(low+high)/2;
            if(abs((n-mid)-mid)==k){
                flag=true;
                break;
            }
            else if((abs((n-mid)-mid))>k){
                high=mid-1;
            }
            else{
                low=mid+1;
            }
        }
        if(flag){
            cout<<0<<endl;
        }
        else{
            cout<<max(n,k)-min(n,k)<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        bool flag=false;
        long long int n,k;
        cin>>n>>k;
        long long int low=0;
        long long int high=n+1;
        while(low<=high){
           long long int mid=(low+high)/2;
           long long int check= abs((mid)-abs(mid-n));
            if(check==k){
                flag=true;
                break;
            }
            else if(check>k){
                high=mid-1;
            }
            else{
                low=mid+1;
            }
        }
        if(flag){
            cout<<0<<endl;
        }
        else{
            cout<<min(abs(n-k),n)<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,k;
        cin>>n>>k;
        if(n<k){
            cout<<abs(n-k)<<endl;
        }
        else{
            if((n%2)==(k%2)){
                cout<<0<<endl;
            }
            else{
                cout<<1<<endl;
            }
        }
    }
}


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
    if(k==0){
        cout<< 0 << endl;
        continue;
        }
    if(n>k){
        cout << n-k<< endl;
    }
    else {
        cout << k << endl;
    }
    }
}


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
    if(k==0){
        cout<< 0 << endl;
        continue;
        }
    if(n>k){
        cout << n-k<< endl;
    }
    else {
        cout << k-n << endl;
    }
    }

    return 0;
}


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
    if(k==0)
        cout<< 0 << endl;
    if(n>k){
        cout << n-k<< endl;
    }
    else {
        cout << k-n << endl;
    }
    }

    return 0;
}


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
     if(k<=n ){
        if(k%2!=n%2)
            cout<<1<<endl;
        else
	    cout<<0<<endl;
        }else
            cout<<k-n<<endl;
	}
    }


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
    if(k==0){
        cout<< 0 << endl;
        continue;
        }
    if(n<k){
        cout <<abs(n-k)<< endl;
    }
    else {
        cout << k << endl;
    }
    }
}


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
    if(k==0){
        cout<< 0 << endl;
        continue;
        }
    if(n<k){
        cout << n-k<< endl;
    }
    else {
        cout << k << endl;
    }
    }
}


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

int main()
{
    int t;
    cin >> t;
    while(t--){
    int n,k;
    cin >> n>>k;
    if(k==0){
        cout<< 0 << endl;
        continue;
        }
    if(n>k){
        cout << n-k<< endl;
    }
    else {
        cout << k-n << endl;
    }
    }
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int ans[2005];
int main(){
	int n, m, t;
	cin >> t;
	for(int i = 0; i < t; ++i){
	    cin >> n >> m;
	    ans[i] = max(n - m, 0);
	}
	for(int i = 0; i < t; ++i)
	    cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int ans[2005];
int main(){
	int n, m, t;
	cin >> t;
	for(int i = 0; i < t; ++i){
	    cin >> n >> m;
	    ans[i] = abs(n - m);
	}
	for(int i = 0; i < t; ++i)
	    cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULDI;
int a[100000];
int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	for(int i = 0; i < n; ++i)
		if(a[i] >= max(a[n - m], 1))
			++ans;
	cout << ans << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int main(){
    int n, m, t;
    cin >> t;
    int ans[t] = {};
    for(int i = 0; i < t; ++i){
        cin >> n >> m;
        if(m <= n){
            if(n % 2 != m % 2)
                ans[i] = 1;
            continue;
        }
        ans[i] = m - n;
    }
    for(int i = 0; i < t; ++i)
        cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int main(){
    int n, m, t;
    cin >> t;
    int ans[t];
    for(int i = 0; i < t; ++i){
        cin >> n >> m;
        if(max(n, m) == n){
            if(n % 2 != m % 2)
                ans[i] = 1;
            continue;
        }
        ans[i] = m - n;
    }
    for(int i = 0; i < t; ++i)
        cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int ans[2005];
int main(){
	int n, m, t;
	cin >> t;
	for(int i = 0; i < t; ++i){
	    cin >> n >> m;
	    ans[i] = max(m - n, 0);
	}
	for(int i = 0; i < t; ++i)
	    cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int main(){
    int n, m, t;
    cin >> t;
    int ans[t] = {};
    for(itn i = 0; i < t; ++i){
        cin >> n >> m;
        if(max(n, m) = n){
            if(n % 2 != m % 2)
                ans[i] = 1;
            continue;
        }
        ans[i] = m - n;
    }
    for(int i = 0; i < t; ++i)
        cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;
//KASRA FOULADI;
int main(){
    int n, m, t;
    cin >> t;
    int ans[t];
    for(itn i = 0; i < t; ++i){
        cin >> n >> m;
        if(max(n, m) = n){
            if(n % 2 != m % 2)
                ans[i] = 1;
            continue;
        }
        ans[i] = m - n;
    }
    for(int i = 0; i < t; ++i)
        cout << ans[i] << '\n';
}


#include <iostream>

#define ll long long

using namespace std;

int main(){
    ll t;
    cin >> t;
    for(ll i = 0; i < t; i++){
        ll n,k;
        cin >> n >> k;
        // x + (x+k) = n => 2x + k = n => x = (n-k)/2
        if((n-k) % 2 == 0 && n != 0)
            cout << 0 << "\n";
        else
            cout << abs(n-k) << "\n";
    }
}


#include <iostream>

#define ll long long

using namespace std;

int main(){
    ll t;
    cin >> t;
    for(ll i = 0; i < t; i++){
        ll n,k;
        cin >> n >> k;
        ll l = 0, r = n;
        bool bak = false;
        while(l < r && !bak){
            ll m = (l+r)/2;
            if(abs(abs(0-m) - abs(m - n)) == k){
                cout << 0 << "\n";
                bak = true;
            }
            else if(abs(abs(0-m) - abs(m - n)) > k)
                r = m;
            else
                l = m;
        }
        if(!bak)
            cout << abs(n - k) << "\n";
    }
}


#include <iostream>

#define ll long long

using namespace std;

int main(){
    ll t;
    cin >> t;
    for(ll i = 0; i < t; i++){
        ll n,k;
        cin >> n >> k;
        if(n % 2 == k % 2 && n > k)
            cout << 0 << "\n";
        else cout << abs(n-k) << "\n";
    }
}


#include <iostream>

#define ll long long

using namespace std;

int main(){
    ll t;
    cin >> t;
    for(ll i = 0; i < t; i++){
        ll n,k;
        cin >> n >> k;
        ll l = 0, r = n;
        bool bak = false;
        while(l <= r && !bak){
            ll m = (l+r)/2;
            if(abs(abs(0-m) - abs(m - n)) == k){
                cout << 0 << "\n";
                bak = true;
            }
            else if(abs(abs(0-m) - abs(m - n)) > k)
                r = m - 1;
            else
                l = m + 1;
        }
        if(!bak)
            cout << abs(n - k) << "\n";
    }
}


#include <iostream>

#define ll long long

using namespace std;

int main(){
    ll t;
    cin >> t;
    for(ll i = 0; i < t; i++){
        ll n,k;
        cin >> n >> k;
        if(n != 0 && k == 0)
            cout << n % 2 << "\n";
        if(n == 0 && k != 0)
            cout << k << "\n";
        if(n != 0 && k != 0)
            cout << abs(n-k) << "\n";
        if(n == 0 && k == 0)
            cout << "0\n";
    }
}


#include <iostream>

#define ll long long

using namespace std;

int main(){
    ll t;
    cin >> t;
    for(ll i = 0; i < t; i++){
        ll n,k;
        cin >> n >> k;
        if(n != 0 && k == 0)
            cout << n % 2 << "\n";
        if(n == 0 && k != 0)
            cout << k << "\n";
        if(n != 0 && k != 0)
            cout << min(abs(n-k),abs(0-k)) << "\n";
        if(n == 0 && k == 0)
            cout << "0\n";
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long>> vpll;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define loop(i,b) for (long long i = 0; i < b; i++)
#define dloop(i,a) for (long long i = a; i >= 0; i--)

struct keycompare {
    bool operator()(const pair<long long, long long>& v, const long long& k) {
        return (v.first < k);
    }
    bool operator()(const long long& k, const pair<long long, long long>& v) {
        return (k < v.first);
    }
};

long long mod1=998244353,mod2=1000000007,limit=9223372036854775807;
long double pi=3.1415926535897932;
long long modpow(long long x, long long n, long long m) {
    if(x>m){
        x%=m;
    }
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
long long gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isprime(long long n){
    if(n==2)
        return true;
    for(long long i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

long long power(long long x,long long n){
    long long x_n=1;
    for(long long i=0;i<n;i++){
        x_n*=x;
    }
    return x_n;
}

vector<int> adj[100005];
int arr[20][100005],height[100005];
bool visited[100005];
void dfs(int node,int parent){
    for(auto it: adj[node]){
        if(it!=parent){
            arr[0][it]=node;
            dfs(it,node);
        }
    }
}

int dist(int a,int b){
    int tempa=a,tempb=b;
    if(height[b]>height[a]){
        swap(a,b);
    }
    int diff=height[a]-height[b];
    string s=bitset< 18 >( diff ).to_string();
    reverse(s.begin(), s.end());
    for(int i=0;i<18;i++){
        if(s[i]=='1'){
            a=arr[i][a];
        }
    }
    while(a!=b){
        int temp=18;
        for(int i=17;i>=0;i--){
            if(arr[a][i]==arr[b][i]){
                temp=i;
            }
        }
        a=arr[temp][a],b=arr[temp][b];
    }
    return height[tempa]+height[tempb]-2*height[a];
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b; cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,0);
    for(int i=1;i<20;i++){
        for(int j=1;j<=n;j++){
            arr[i][j]=arr[i-1][arr[i-1][j]];
        }
    }
    height[1]=0;
    visited[1]=true;
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int node=q.front(); q.pop();
        for(auto it: adj[node]){
            if(!visited[it]){
                visited[it]=true;
                height[it]=height[node]+1;
                q.push(it);
            }
        }
    }
    int t; cin>>t;
    while(t--){
        int x,y,a,b,k; cin>>x>>y>>a>>b>>k;
        int x1=dist(a,b),x2=dist(a,x)+dist(x,b),x3=dist(a,y)+dist(y,b),x4=min(dist(a,x)+1+dist(y,b),dist(a,y)+1+dist(x,b));
        // cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl;
        if((k-x1)>=0 && (k-x1)%2==0){
            cout<<"YES\n";
        }else if((k-x2)>=0 && (k-x2)%2==0){
            cout<<"YES\n";
        }else if((k-x3)>=0 && (k-x3)%2==0){
            cout<<"YES\n";
        }else if((k-x4)>=0 && (k-x4)%2==0){
            cout<<"YES\n";
        }else{
            cout<<"NO\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long>> vpll;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define loop(i,b) for (long long i = 0; i < b; i++)
#define dloop(i,a) for (long long i = a; i >= 0; i--)

struct keycompare {
    bool operator()(const pair<long long, long long>& v, const long long& k) {
        return (v.first < k);
    }
    bool operator()(const long long& k, const pair<long long, long long>& v) {
        return (k < v.first);
    }
};

long long mod1=998244353,mod2=1000000007,limit=9223372036854775807;
long double pi=3.1415926535897932;
long long modpow(long long x, long long n, long long m) {
    if(x>m){
        x%=m;
    }
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
long long gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isprime(long long n){
    if(n==2)
        return true;
    for(long long i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

long long power(long long x,long long n){
    long long x_n=1;
    for(long long i=0;i<n;i++){
        x_n*=x;
    }
    return x_n;
}

vector<ll> adj[100005];
ll arr[20][100005],height[100005];
bool visited[100005];
void dfs(ll node,ll parent){
    for(auto it: adj[node]){
        if(it!=parent){
            arr[0][it]=node;
            dfs(it,node);
        }
    }
}

ll dist(ll a,ll b){
    ll tempa=a,tempb=b;
    if(height[b]>height[a]){
        swap(a,b);
    }
    ll diff=height[a]-height[b];
    string s=bitset< 18 >( diff ).to_string();
    reverse(s.begin(), s.end());
    for(ll i=0;i<18;i++){
        if(s[i]=='1'){
            a=arr[i][a];
        }
    }
    while(a!=b){
        ll temp=0;
        for(ll i=0;i<18;i++){
            if(arr[i][a]!=arr[i][b]){
                temp=i;
            }else{
                break;
            }
        }
        a=arr[temp][a],b=arr[temp][b];
    }
    return height[tempa]+height[tempb]-2*height[a];
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    for(ll i=0;i<n-1;i++){
        ll a,b; cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,0);
    for(ll i=1;i<20;i++){
        for(ll j=1;j<=n;j++){
            arr[i][j]=arr[i-1][arr[i-1][j]];
        }
    }
    height[1]=0;
    visited[1]=true;
    queue<ll>q;
    q.push(1);
    while(!q.empty()){
        ll node=q.front(); q.pop();
        for(auto it: adj[node]){
            if(!visited[it]){
                visited[it]=true;
                height[it]=height[node]+1;
                q.push(it);
            }
        }
    }
    ll t; cin>>t;
    while(t--){
        ll x,y,a,b,k; cin>>x>>y>>a>>b>>k;
        ll x1=dist(a,b),x2=dist(a,x)+dist(x,b),x3=dist(a,y)+dist(y,b),x4=dist(a,x)+1+dist(y,b),x5=dist(a,y)+1+dist(x,b);
        // cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl;
        if((k-x1)>=0 && (k-x1)%2==0){
            cout<<"YES\n";
        }else if((k-x2)>=0 && (k-x2)%2==0){
            cout<<"YES\n";
        }else if((k-x3)>=0 && (k-x3)%2==0){
            cout<<"YES\n";
        }else if((k-x4)>=0 && (k-x4)%2==0){
            cout<<"YES\n";
        }else if((k-x5)>=0 && (k-x5)%2==0){
            cout<<"YES\n";
        }else{
            cout<<"NO\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long>> vpll;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define loop(i,b) for (long long i = 0; i < b; i++)
#define dloop(i,a) for (long long i = a; i >= 0; i--)

struct keycompare {
    bool operator()(const pair<long long, long long>& v, const long long& k) {
        return (v.first < k);
    }
    bool operator()(const long long& k, const pair<long long, long long>& v) {
        return (k < v.first);
    }
};

long long mod1=998244353,mod2=1000000007,limit=9223372036854775807;
long double pi=3.1415926535897932;
long long modpow(long long x, long long n, long long m) {
    if(x>m){
        x%=m;
    }
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
long long gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isprime(long long n){
    if(n==2)
        return true;
    for(long long i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

long long power(long long x,long long n){
    long long x_n=1;
    for(long long i=0;i<n;i++){
        x_n*=x;
    }
    return x_n;
}

vector<int> adj[100005];
int arr[20][100005],height[100005];
bool visited[100005];
void dfs(int node,int parent){
    for(auto it: adj[node]){
        if(it!=parent){
            arr[0][it]=node;
            dfs(it,node);
        }
    }
}

int dist(int a,int b){
    int tempa=a,tempb=b;
    if(height[b]>height[a]){
        swap(a,b);
    }
    int diff=height[a]-height[b];
    string s=bitset< 18 >( diff ).to_string();
    reverse(s.begin(), s.end());
    for(int i=0;i<18;i++){
        if(s[i]=='1'){
            a=arr[i][a];
        }
    }
    while(a!=b){
        int temp=18;
        for(int i=17;i>=0;i--){
            if(arr[i][a]==arr[i][b]){
                temp=i;
            }
        }
        a=arr[temp][a],b=arr[temp][b];
    }
    return height[tempa]+height[tempb]-2*height[a];
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b; cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,0);
    for(int i=1;i<20;i++){
        for(int j=1;j<=n;j++){
            arr[i][j]=arr[i-1][arr[i-1][j]];
        }
    }
    height[1]=0;
    visited[1]=true;
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int node=q.front(); q.pop();
        for(auto it: adj[node]){
            if(!visited[it]){
                visited[it]=true;
                height[it]=height[node]+1;
                q.push(it);
            }
        }
    }
    int t; cin>>t;
    while(t--){
        int x,y,a,b,k; cin>>x>>y>>a>>b>>k;
        int x1=dist(a,b),x2=dist(a,x)+dist(x,b),x3=dist(a,y)+dist(y,b),x4=min(dist(a,x)+1+dist(y,b),dist(a,y)+1+dist(x,b));
        // cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl;
        if((k-x1)>=0 && (k-x1)%2==0){
            cout<<"YES\n";
        }else if((k-x2)>=0 && (k-x2)%2==0){
            cout<<"YES\n";
        }else if((k-x3)>=0 && (k-x3)%2==0){
            cout<<"YES\n";
        }else if((k-x4)>=0 && (k-x4)%2==0){
            cout<<"YES\n";
        }else{
            cout<<"NO\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long>> vpll;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define loop(i,b) for (long long i = 0; i < b; i++)
#define dloop(i,a) for (long long i = a; i >= 0; i--)

struct keycompare {
    bool operator()(const pair<long long, long long>& v, const long long& k) {
        return (v.first < k);
    }
    bool operator()(const long long& k, const pair<long long, long long>& v) {
        return (k < v.first);
    }
};

long long mod1=998244353,mod2=1000000007,limit=9223372036854775807;
long double pi=3.1415926535897932;
long long modpow(long long x, long long n, long long m) {
    if(x>m){
        x%=m;
    }
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
long long gcd(long long a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isprime(long long n){
    if(n==2)
        return true;
    for(long long i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

long long power(long long x,long long n){
    long long x_n=1;
    for(long long i=0;i<n;i++){
        x_n*=x;
    }
    return x_n;
}

vector<ll> adj[100005];
ll arr[20][100005],height[100005]={0};
bool visited[100005];
void dfs(ll node,ll parent){
    for(auto it: adj[node]){
        if(it!=parent){
            arr[0][it]=node;
            dfs(it,node);
        }
    }
}

ll dist(ll a,ll b){
    ll tempa=a,tempb=b;
    if(height[b]>height[a]){
        swap(a,b);
    }
    ll diff=height[a]-height[b];
    string s=bitset< 18 >( diff ).to_string();
    reverse(s.begin(), s.end());
    for(ll i=0;i<18;i++){
        if(s[i]=='1'){
            a=arr[i][a];
        }
    }
    while(a!=b){
        ll temp=18;
        for(ll i=17;i>=0;i--){
            if(arr[i][a]==arr[i][b]){
                temp=i;
            }
        }
        a=arr[temp][a],b=arr[temp][b];
    }
    return height[tempa]+height[tempb]-2*height[a];
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    for(ll i=0;i<n-1;i++){
        ll a,b; cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,0);
    for(ll i=1;i<20;i++){
        for(ll j=1;j<=n;j++){
            arr[i][j]=arr[i-1][arr[i-1][j]];
        }
    }
    height[1]=0;
    visited[1]=true;
    queue<ll>q;
    q.push(1);
    while(!q.empty()){
        ll node=q.front(); q.pop();
        for(auto it: adj[node]){
            if(!visited[it]){
                visited[it]=true;
                height[it]=height[node]+1;
                q.push(it);
            }
        }
    }
    ll t; cin>>t;
    while(t--){
        ll x,y,a,b,k; cin>>x>>y>>a>>b>>k;
        ll x1=dist(a,b),x2=dist(a,x)+dist(x,b),x3=dist(a,y)+dist(y,b),x4=dist(a,x)+1+dist(y,b),x5=dist(a,y)+1+dist(x,b);
        // cout<<x1<<" "<<x2<<" "<<x3<<" "<<x4<<endl;
        if((k-x1)>=0 && (k-x1)%2==0){
            cout<<"YES\n";
        }else if((k-x2)>=0 && (k-x2)%2==0){
            cout<<"YES\n";
        }else if((k-x3)>=0 && (k-x3)%2==0){
            cout<<"YES\n";
        }else if((k-x4)>=0 && (k-x4)%2==0){
            cout<<"YES\n";
        }else if((k-x5)>=0 && (k-x5)%2==0){
            cout<<"YES\n";
        }else{
            cout<<"NO\n";
        }
    }
}


//keep calm :)
#include <bits/stdc++.h>
#define float long double
#define int long long
//#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.1415926535897932384
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int M = 3e5 + 5, mod = 998244353;

int dp[M][25], level[M], V[M];
vector <int> g[M];

void dfs(int n, int p){
    V[n] = 1;
    if(p != -1)
        level[n] = level[p] + 1;
    dp[n][0] = p;
    for(int i = 1; i < 25; i++){
        if(dp[n][i - 1] == -1)
            break;
        dp[n][i] = dp[dp[n][i - 1]][i - 1];
    }
    for(int i = 0; i < g[n].size(); i++){
        if(V[g[n][i]] == 0)
            dfs(g[n][i], n);
    }
}

int lca(int u, int v){
    if(level[u] < level[v])
        swap(u, v);
    int diff = level[u] - level[v];
    for(int i = 0; i <= 60; i++){
        if(diff % 2 == 1)
            u = dp[u][i];
        diff >>= 1;
    }
    if(u == v)
        return u;
    for(int i = 60; i >= 0; i--){
        if(dp[u][i] != dp[v][i]){
            u = dp[u][i];
            v = dp[v][i];
        }
    }
    return dp[u][0];
}

int dist(int x, int y){
    int par = lca(x, y);
    return (level[x] - level[par]) + (level[y] - level[par]);
}

void preprocess(void){
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        g[x].PB(y);
        g[y].PB(x);
    }
    dfs(1, -1);
}

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        preprocess();
        int q;
        cin >> q;
        while(q--){
            int x, y, a, b, k;
            cin >> x >> y >> a >> b >> k;
            int d = dist(a, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a,  x) + 1 + dist(y, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a, y) + 1 + dist(x, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            cout << "NO" << "\n";
        }
    }
    return 0;
}


//keep calm :)
#include <bits/stdc++.h>
#define float long double
#define int long long
//#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.1415926535897932384
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int M = 5e3 + 5, mod = 998244353;

int n, l;

vector <int> adj[M];

int timer, h[M], tin[M], tout[M], up[M][25];

void dfs(int v, int p){
    tin[v] = ++timer;
    if(v != p)
        h[v] = h[p] + 1;
    up[v][0] = p;
    for (int i = 1; i <= l; ++i)
        up[v][i] = up[up[v][i-1]][i-1];
    for (int u : adj[v]) {
        if (u != p)
            dfs(u, v);
    }
    tout[v] = ++timer;
}

bool is_ancestor(int u, int v){
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v){
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

int dist(int x, int y){
    int par = lca(x, y);
    return (h[x] - h[par]) + (h[y] - h[par]);
}

void preprocess(void){
    cin >> n;
    timer = 0;
    l = ceil(log2(n + 1));
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        adj[x].PB(y);
        adj[y].PB(x);
    }
}

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        preprocess();
        dfs(1, 1);
        int q;
        cin >> q;
        while(q--){
            int x, y, a, b, k;
            cin >> x >> y >> a >> b >> k;
            int d = dist(a, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a,  x) + 1 + dist(y, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a, y) + 1 + dist(x, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            cout << "NO" << "\n";
        }
    }
    return 0;
}


//keep calm :)
#include <bits/stdc++.h>
#define float long double
#define int long long
//#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.1415926535897932384
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int M = 3e5 + 5, mod = 998244353;

int n, l;

vector <int> adj[M];

int timer, h[M], tin[M], tout[M], up[M][25];

void dfs(int v, int p){
    tin[v] = ++timer;
    if(v != p)
        h[v] = h[p] + 1;
    up[v][0] = p;
    for (int i = 1; i <= l; ++i)
        up[v][i] = up[up[v][i-1]][i-1];
    for (int u : adj[v]) {
        if (u != p)
            dfs(u, v);
    }
    tout[v] = ++timer;
}

bool is_ancestor(int u, int v){
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v){
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

int dist(int x, int y){
    int par = lca(x, y);
    return (h[x] - h[par]) + (h[y] - h[par]);
}

void preprocess(void){
    cin >> n;
    timer = 0;
    l = ceil(log2(n + 1));
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        adj[x].PB(y);
        adj[y].PB(x);
    }
}

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        preprocess();
        dfs(1, 1);
        int q;
        cin >> q;
        while(q--){
            int x, y, a, b, k;
            cin >> x >> y >> a >> b >> k;
            int d = dist(a, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a,  x) + 1 + dist(y, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a, y) + 1 + dist(x, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            cout << "NO" << "\n";
        }
    }
    return 0;
}


//keep calm :)
#include <bits/stdc++.h>
#define float long double
#define int long long
//#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.1415926535897932384
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int M = 3e5 + 5, mod = 998244353;

int dp[M][65], level[M], V[M];
vector <int> g[M];

void dfs(int n, int p){
    V[n] = 1;
    if(p != -1)
        level[n] = level[p] + 1;
    dp[n][0] = p;
    for(int i = 1; i <= 60; i++){
        if(dp[n][i - 1] == -1)
            break;
        dp[n][i] = dp[dp[n][i - 1]][i - 1];
    }
    for(int i = 0; i < g[n].size(); i++){
        if(V[g[n][i]] == 0)
            dfs(g[n][i], n);
    }
}

int lca(int u, int v){
    if(level[u] < level[v])
        swap(u, v);
    int diff = level[u] - level[v];
    for(int i = 0; i <= 60; i++){
        if(diff % 2 == 1)
            u = dp[u][i];
        diff >>= 1;
    }
    if(u == v)
        return u;
    for(int i = 60; i >= 0; i--){
        if(dp[u][i] != dp[v][i]){
            u = dp[u][i];
            v = dp[v][i];
        }
    }
    return dp[u][0];
}

int dist(int x, int y){
    int par = lca(x, y);
    return (level[x] - level[par]) + (level[y] - level[par]);
}

void preprocess(void){
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        g[x].PB(y);
        g[y].PB(x);
    }
    dfs(1, -1);
}

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        preprocess();
        int q;
        cin >> q;
        while(q--){
            int x, y, a, b, k;
            cin >> x >> y >> a >> b >> k;
            int d = dist(a, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a,  x) + 1 + dist(y, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a, y) + 1 + dist(x, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            cout << "NO" << "\n";
        }
    }
    return 0;
}


//keep calm :)
#include <bits/stdc++.h>
#define float long double
#define int long long
//#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.1415926535897932384
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int M = 3e5 + 5, mod = 998244353;

int dp[M][25], level[M], V[M];
vector <int> g[M];

void dfs(int n, int p){
    V[n] = 1;
    if(p != -1)
        level[n] = level[p] + 1;
    dp[n][0] = p;
    for(int i = 1; i < 25; i++){
        if(dp[n][i - 1] == -1)
            break;
        dp[n][i] = dp[dp[n][i - 1]][i - 1];
    }
    for(int i = 0; i < g[n].size(); i++){
        if(V[g[n][i]] == 0)
            dfs(g[n][i], n);
    }
}

int lca(int u, int v){
    if(level[u] < level[v])
        swap(u, v);
    int diff = level[u] - level[v];
    for(int i = 0; i < 25; i++){
        if(diff % 2 == 1)
            u = dp[u][i];
        diff >>= 1;
    }
    if(u == v)
        return u;
    for(int i = 24; i >= 0; i--){
        if(dp[u][i] != dp[v][i]){
            u = dp[u][i];
            v = dp[v][i];
        }
    }
    return dp[u][0];
}

int dist(int x, int y){
    int par = lca(x, y);
    return (level[x] - level[par]) + (level[y] - level[par]);
}

void preprocess(void){
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        g[x].PB(y);
        g[y].PB(x);
    }
    dfs(1, -1);
}

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        preprocess();
        int q;
        cin >> q;
        while(q--){
            int x, y, a, b, k;
            cin >> x >> y >> a >> b >> k;
            int d = dist(a, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a,  x) + 1 + dist(y, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            d = dist(a, y) + 1 + dist(x, b);
            if(k - d >= 0 && (k - d)%2 == 0){
                cout << "YES" << "\n";
                continue;
            }
            cout << "NO" << "\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<ll> G[MaxN];
vector<vector<ll>> P(MaxN,vector<ll>(LogN,-1));
vector<ll> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

ll LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 1 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

ll Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    ll x,y,a,b,k;
    scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    if(D == k){
      puts("YES");
      continue;
    }
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;
    bool Is1 = D1 > k;
    bool Is2 = D2 > k;
    if(Is1 && Is2){
      puts("NO");
      continue;
    }
    if(D1 == k || D2 == k){
      puts("YES");
      continue;
    }
    int L1 = k - D1;
    int L2 = k - D2;
    int L3 = k - D;
    int LoopLen = Distance(x,y) + 1;

    if(L1 % 2 == 0 || L2 % 2 == 0 || L3 % 2 == 0 || (LoopLen & 1))
      puts("YES");
    else
      puts("NO");
  }

}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<ll> G[MaxN];
vector<vector<ll>> P(MaxN,vector<ll>(LogN,-1));
vector<ll> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

ll LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 1 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

ll Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    ll x,y,a,b,k;
    scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;

    if(D <= k && D % 2 == k % 2){
      puts("YES"); continue;
    }
    if(D1 <= k && D1 % 2 == k % 2){
      puts("YES"); continue;
    }
    if(D2 <= k && D2 % 2 == k % 2){
      puts("YES"); continue;
    }

    puts("NO");
  }

}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<ll> G[MaxN];
vector<vector<ll>> P(MaxN,vector<ll>(LogN,-1));
vector<ll> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

ll LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 1 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

ll Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    ll x,y,a,b,k;
    scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    if(D == k){
      puts("YES");
      continue;
    }
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;
    bool Is1 = D1 > k;
    bool Is2 = D2 > k;
    if(Is1 && Is2){
      puts("NO");
      continue;
    }
    if(D1 == k || D2 == k){
      puts("YES");
      continue;
    }
    int L1 = k - D1;
    int L2 = k - D2;
    int L3 = k - D;
    int LoopLen = Distance(x,y) + 1;

    if(L1 % 2 == k % 2 || L2 % 2 == k % 2 || L3 % 2 == k % 2)
      puts("YES");
    else
      puts("NO");
  }

}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<ll> G[MaxN];
vector<vector<ll>> P(MaxN,vector<ll>(LogN,-1));
vector<ll> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

ll LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 1 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

ll Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    ll x,y,a,b,k;
    scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    if(D == k){
      puts("YES");
      continue;
    }
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;
    bool Is1 = D1 > k;
    bool Is2 = D2 > k;
    if(Is1 && Is2){
      puts("NO");
      continue;
    }
    if(D1 == k || D2 == k){
      puts("YES");
      continue;
    }
    int L1 = k - D1;
    int L2 = k - D2;
    int L3 = k - D;
    if(L1 % 2 == 0 || L2 % 2 == 0 || L3 % 2 == 0)
      puts("YES");
    else
      puts("NO");
  }

}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<int> G[MaxN];
vector<vector<int>> P(MaxN,vector<int>(LogN,-1));
vector<int> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

int LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 2 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

int Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    int x,y,a,b,k;
    scanf("%d %d %d %d %d",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    if(D == k){
      puts("YES");
      continue;
    }
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;
    bool Is1 = D1 > k;
    bool Is2 = D2 > k;
    if(Is1 && Is2){
      puts("NO");
      continue;
    }
    if(D1 == k || D2 == k){
      puts("YES");
      continue;
    }
    int LoopLen = Distance(x,y) + 1;
    int Net = k - Distance(a,x) - Distance(y,b) - 1;

    if(Net % LoopLen == 0){
      puts("YES");
      continue;
    }
    Net = k - Distance(a,y) - Distance(x,b) - 1;
    if(Net % LoopLen == 0){
      puts("YES");
      continue;
    }
    puts("NO");
  }

}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<ll> G[MaxN];
vector<vector<ll>> P(MaxN,vector<ll>(LogN,-1));
vector<ll> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

ll LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 1 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

ll Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    ll x,y,a,b,k;
    scanf("%lld %lld %lld %lld %lld",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    if(D == k){
      puts("YES");
      continue;
    }
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;
    bool Is1 = D1 > k;
    bool Is2 = D2 > k;
    if(Is1 && Is2){
      puts("NO");
      continue;
    }
    if(D1 == k || D2 == k){
      puts("YES");
      continue;
    }
    int LoopLen = Distance(x,y) + 1;
    int Net = k - Distance(a,x) - Distance(y,b) - 1;

    if(Net % LoopLen == 0){
      puts("YES");
      continue;
    }
    Net = k - Distance(a,y) - Distance(x,b) - 1;
    if(Net % LoopLen == 0){
      puts("YES");
      continue;
    }
    puts("NO");
  }

}


#include <bits/stdc++.h>
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MaxN = 1e5 + 5;
const int LogN = log2(MaxN) + 2;

vector<int> G[MaxN];
vector<vector<int>> P(MaxN,vector<int>(LogN,-1));
vector<int> LvL(MaxN);
int n;
int q;

void DFS(int x,int p = -1,int l = 0){
  P[x][0] = p;
  LvL[x] = l;
  for(auto v : G[x]){
    if(v == p) continue;
    DFS(v,x,l + 1);
  }
}

void MakeLCA(){
  for(int j = 1 ; (1 << j) < n ; ++j){
    for(int i = 1 ; i <= n ; ++i){
      if(P[i][j - 1] != -1){
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}

int LCA(int x,int y){
  if(LvL[x] < LvL[y])
    swap(x,y);
  int d = LvL[x] - LvL[y];
  while(d > 0){
    int r = log2(d);
    x = P[x][r];
    d -= (1 << r);
  }
  if(x == y) return x;
  for(int i = LogN - 1 ; i >= 0 ; --i){
    if(P[x][i] != -1 && P[x][i] != P[y][i]){
      x = P[x][i];
      y = P[y][i];
    }
  }
  return P[x][0];
}

int Distance(int x,int y){
  return LvL[x] + LvL[y] - 2 * LvL[LCA(x,y)];
}

int main(){
  scanf("%d",&n);
  for(int i = 0 ; i < n - 1; ++i){
    int x,y; scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int start = 1;
  for(int i = 1 ; i <= n ; ++i){
    if(G[i].size() > 1){
      start = i; break;
    }
  }

  DFS(start);
  MakeLCA();
  scanf("%d",&q);

  int tc = 0;

  while(q--){
    tc++;
    int x,y,a,b,k;
    scanf("%d %d %d %d %d",&x,&y,&a,&b,&k);
    int D = Distance(a,b);
    if(D == k){
      puts("YES");
      continue;
    }
    int D1 = Distance(a,y) + Distance(x,b) + 1;
    int D2 = Distance(a,x) + Distance(y,b) + 1;
    bool Is1 = D1 > k;
    bool Is2 = D2 > k;
    if(Is1 && Is2){
      puts("NO");
      continue;
    }
    if(D1 == k || D2 == k){
      puts("YES");
      continue;
    }
    int LoopLen = Distance(x,y) + 1;
    int Net = k - Distance(a,x) - Distance(y,b) - 1;

    if(Net % LoopLen == 0){
      puts("YES");
      continue;
    }
    Net = k - Distance(a,y) - Distance(x,b) - 1;
    if(Net % LoopLen == 0){
      puts("YES");
      continue;
    }
    puts("NO");
  }

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

vi adj[100005];

const ll N = 100001;
const ll M = log2(N) + 1;

ll depth[N], anc[N][M], val[N][M];

void build(ll x, ll p, ll d = 0)
{
    anc[x][0] = p;
    depth[x] = d;
    for(int i = 1; i < M; i++)
    {
        anc[x][i] = anc[anc[x][i - 1]][i - 1];
    }
    for(auto i:adj[x])
    {
        if(i != p) build(i, x, d + 1);
    }
}

ll LCA(ll l, ll r)
{
    if(depth[l] != depth[r])
    {
        if(depth[l] > depth[r])
        swap(l, r);
        ll x = depth[r] - depth[l];
        for(int i = M - 1; i > -1; i--)
           if(x & (1ll << i)) r = anc[r][i];
    }
    if(l == r) return l;
    for(int i = M - 1; i > -1; i--)
    {
        if(anc[l][i] != anc[r][i])
        {
            l = anc[l][i];
            r = anc[r][i];
        }
    }
    return anc[l][0];
}

int dis(int u,int v)
{
    return depth[u]+depth[v]-2*depth[LCA(u,v)];
}

void solve()
{
    //cout << "-------------------" << "\n";

    int n;
    cin>>n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    build(1, 0);

     int q;
    cin>>q;

    while(q--)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;

        int a1 = dis(a,b);
        int a2 = dis(a,x)+1+dis(b,y);
        int a3 = dis(a,y)+1+dis(b,x);

        if((a1<=k && k%2==a1%2) || (a2<=k && a2%2==k%2) || (a3<=k && a3%2==k%2))
        cout<<"YES"<<"\n";
        else
        cout<<"NO"<<"\n";
    }

   // cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

vi adj[100005];
int visited[100005],height[100005],first[100005],segtree[400005];
vi euler;

    void dfs(int node, int h = 0) {
        visited[node] = true;
        height[node] = h;
        first[node] = euler.size();
        euler.push_back(node);
        for (auto to : adj[node]) {
            if (!visited[to]) {
                dfs(to, h + 1);
                euler.push_back(node);
            }
        }
    }

    void build(int node, int b, int e) {
        if (b == e) {
            segtree[node] = euler[b];
        } else {
            int mid = (b + e) / 2;
            build(node << 1, b, mid);
            build(node << 1 | 1, mid + 1, e);
            int l = segtree[node << 1], r = segtree[node << 1 | 1];
            segtree[node] = (height[l] < height[r]) ? l : r;
        }
    }

    int query(int node, int b, int e, int L, int R) {
        if (b > R || e < L)
            return -1;
        if (b >= L && e <= R)
            return segtree[node];
        int mid = (b + e) >> 1;

        int left = query(node << 1, b, mid, L, R);
        int right = query(node << 1 | 1, mid + 1, e, L, R);

        if (left == -1) return right;
        if (right == -1) return left;
        return height[left] < height[right] ? left : right;
    }

    int lca(int u, int v) {
        int left = first[u], right = first[v];
        if (left > right)
            swap(left, right);
        return query(1, 0, euler.size() - 1, left, right);
    }

   int dis(int u,int v)
   {
       return height[u]+height[v]-2*height[lca(u,v)];
   }

void solve()
{
    //cout << "-------------------" << "\n";

    int n;
    cin>>n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    memset(visited,0,sizeof(visited));

    dfs(1);

    build(1,0,euler.size()-1);

    int q;
    cin>>q;

    while(q--)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;

        int a1 = dis(a,b);
        int a2 = dis(a,x)+1+dis(b,y);
        int a3 = dis(a,y)+1+dis(b,x);

        if((a1<=k && (k-a1)%2==0) || (a2<=k && (k-a2)%2==0) || (a3<=k && (k-a2)%2==0))
        cout<<"YES"<<"\n";
        else
        cout<<"NO"<<"\n";
    }

   // cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

vi adj[100005];
int visited[100005],height[100005],first[100005],segtree[400005];
vi euler;

    void dfs(int node, int h = 0) {
        visited[node] = true;
        height[node] = h;
        first[node] = euler.size();
        euler.push_back(node);
        for (auto to : adj[node]) {
            if (!visited[to]) {
                dfs(to, h + 1);
                euler.push_back(node);
            }
        }
    }

    void build(int node, int b, int e) {
        if (b == e) {
            segtree[node] = euler[b];
        } else {
            int mid = (b + e) / 2;
            build(node << 1, b, mid);
            build(node << 1 | 1, mid + 1, e);
            int l = segtree[node << 1], r = segtree[node << 1 | 1];
            segtree[node] = (height[l] < height[r]) ? l : r;
        }
    }

    int query(int node, int b, int e, int L, int R) {
        if (b > R || e < L)
            return -1;
        if (b >= L && e <= R)
            return segtree[node];
        int mid = (b + e) >> 1;

        int left = query(node << 1, b, mid, L, R);
        int right = query(node << 1 | 1, mid + 1, e, L, R);

        if (left == -1) return right;
        if (right == -1) return left;
        return height[left] < height[right] ? left : right;
    }

    int lca(int u, int v) {
        int left = first[u], right = first[v];
        if (left > right)
            swap(left, right);
        return query(1, 0, euler.size() - 1, left, right);
    }

   int dis(int u,int v)
   {
       return height[u]+height[v]-2*height[lca(u,v)];
   }

void solve()
{
    //cout << "-------------------" << "\n";

    int n;
    cin>>n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    memset(visited,0,sizeof(visited));

    dfs(1);

    build(1,0,euler.size()-1);

    int q;
    cin>>q;

    while(q--)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;

        int a1 = dis(a,b);
        int a2 = dis(a,x)+1+dis(b,y);
        int a3 = dis(a,y)+1+dis(b,x);

        if((a1<=k && ((k^a1)&1)==0) || (a2<=k && ((k^a2)&1)==0) || (a3<=k && ((k^a3)&1)==0))
        cout<<"YES"<<"\n";
        else
        cout<<"NO"<<"\n";
    }

   // cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

vi adj[100005];
int visited[100005],height[100005],first[100005],segtree[400005];
vi euler;

    void dfs(int node, int h = 0) {
        visited[node] = true;
        height[node] = h;
        first[node] = euler.size();
        euler.push_back(node);
        for (auto to : adj[node]) {
            if (!visited[to]) {
                dfs(to, h + 1);
                euler.push_back(node);
            }
        }
    }

    void build(int node, int b, int e) {
        if (b == e) {
            segtree[node] = euler[b];
        } else {
            int mid = (b + e) / 2;
            build(node << 1, b, mid);
            build(node << 1 | 1, mid + 1, e);
            int l = segtree[node << 1], r = segtree[node << 1 | 1];
            segtree[node] = (height[l] < height[r]) ? l : r;
        }
    }

    int query(int node, int b, int e, int L, int R) {
        if (b > R || e < L)
            return -1;
        if (b >= L && e <= R)
            return segtree[node];
        int mid = (b + e) >> 1;

        int left = query(node << 1, b, mid, L, R);
        int right = query(node << 1 | 1, mid + 1, e, L, R);

        if (left == -1) return right;
        if (right == -1) return left;
        return height[left] < height[right] ? left : right;
    }

    int lca(int u, int v) {
        int left = first[u], right = first[v];
        if (left > right)
            swap(left, right);
        return query(1, 0, euler.size() - 1, left, right);
    }

   int dis(int u,int v)
   {
       return height[u]+height[v]-2*height[lca(u,v)];
   }

void solve()
{
    //cout << "-------------------" << "\n";

    int n;
    cin>>n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    memset(visited,0,sizeof(visited));

    dfs(1);

    build(1,0,euler.size()-1);

    int q;
    cin>>q;

    while(q--)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;

        int a1 = dis(a,b);
        int a2 = dis(a,x)+1+dis(b,y);
        int a3 = dis(a,y)+1+dis(b,x);

        if((a1<=k && k%2==a1%2) || (a2<=k && a2%2==k%2) || (a3<=k && a3%2==k%2))
        cout<<"YES"<<"\n";
        else
        cout<<"NO"<<"\n";
    }

   // cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

vi adj[100005];
int visited[100005],height[100005],first[100005],segtree[400005];
vi euler;

    void dfs(int node, int h = 0) {
        visited[node] = true;
        height[node] = h;
        first[node] = euler.size();
        euler.push_back(node);
        for (auto to : adj[node]) {
            if (!visited[to]) {
                dfs(to, h + 1);
                euler.push_back(node);
            }
        }
    }

    void build(int node, int b, int e) {
        if (b == e) {
            segtree[node] = euler[b];
        } else {
            int mid = (b + e) / 2;
            build(node << 1, b, mid);
            build(node << 1 | 1, mid + 1, e);
            int l = segtree[node << 1], r = segtree[node << 1 | 1];
            segtree[node] = (height[l] < height[r]) ? l : r;
        }
    }

    int query(int node, int b, int e, int L, int R) {
        if (b > R || e < L)
            return -1;
        if (b >= L && e <= R)
            return segtree[node];
        int mid = (b + e) >> 1;

        int left = query(node << 1, b, mid, L, R);
        int right = query(node << 1 | 1, mid + 1, e, L, R);

        if (left == -1) return right;
        if (right == -1) return left;
        return height[left] < height[right] ? left : right;
    }

    int lca(int u, int v) {
        int left = first[u], right = first[v];
        if (left > right)
            swap(left, right);
        return query(1, 0, euler.size() - 1, left, right);
    }

   int dis(int u,int v)
   {
       return height[u]+height[v]-2*height[lca(u,v)];
   }

void solve()
{
    //cout << "-------------------" << "\n";

    int n;
    cin>>n;

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    memset(visited,0,sizeof(visited));

    dfs(1);

    build(1,0,euler.size()-1);

    int q;
    cin>>q;

    while(q--)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;

        int a1 = dis(a,b);
        int a2 = dis(a,x)+1+dis(b,y);
        int a3 = dis(a,y)+1+dis(b,x);

        if((a1<=k && (k-a1)%2==0) || (a2<=k && (k-a2)%2==0) || (a3<=k && (k-a3)%2==0))
        cout<<"YES"<<"\n";
        else
        cout<<"NO"<<"\n";
    }

   // cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
            dfs_clock++;
            lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
        }
    }
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
    }
    else
    {
        int mid = left+(right-left)/2;
        if(p <= mid)
            update(o*2,left,mid);
        else if(p > mid)
            update(o*2+1,mid+1,right);
        if(tree[o*2].d <= tree[o*2].d)
            tree[o] = tree[o*2];
        else
            tree[o] = tree[o*2+1];
    }
}

int L,R;
node ans;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < ans.d)
        {
            ans = tree[o];
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        ans.d = 1e9; L = min(see[x],see[y]); R = max(see[x],see[y]);
        query(1,1,dfs_clock);
        int p0 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[b]); R = max(see[a],see[b]);
        query(1,1,dfs_clock);
        int p1 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[x]); R = max(see[a],see[x]);
        query(1,1,dfs_clock);
        int p2 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[y]); R = max(see[a],see[y]);
        query(1,1,dfs_clock);
        int p3 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[x]); R = max(see[b],see[x]);
        query(1,1,dfs_clock);
        int p4 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[y]); R = max(see[b],see[y]);
        query(1,1,dfs_clock);
        int p5 = ans.pos;
        int dd[10];
        int dax = dist[a]+dist[x]-2*dist[p2];
        int day = dist[a]+dist[y]-2*dist[p3];
        int dbx = dist[b]+dist[x]-2*dist[p4];
        int dby = dist[b]+dist[y]-2*dist[p5];
        int dxy = dist[x]+dist[y]-2*dist[p0];
        int dab = dist[a]+dist[b]-2*dist[p1];
        dd[1] = dab; dd[2] = dax+dby+dxy; dd[3] = dax+dby+1;
        dd[4] = day+dbx+dxy; dd[5] = day+dbx+1;
        int flag = 0;
        for(int i = 1; i <= 5; i++)
        {
            if(k >= dd[i]&&k%2==dd[i]%2)
                flag = 1;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
        }
    }
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
    }
    else
    {
        int mid = left+(right-left)/2;
        if(p <= mid)
            update(o*2,left,mid);
        else if(p > mid)
            update(o*2+1,mid+1,right);
        if(tree[o*2].d <= tree[o*2].d)
            tree[o] = tree[o*2];
        else
            tree[o] = tree[o*2+1];
    }
}

int L,R;
node ans;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < ans.d)
        {
            ans = tree[o];
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        ans.d = 1e9; L = min(see[x],see[y]); R = max(see[x],see[y]);
        query(1,1,dfs_clock);
        int p0 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[b]); R = max(see[a],see[b]);
        query(1,1,dfs_clock);
        int p1 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[x]); R = max(see[a],see[x]);
        query(1,1,dfs_clock);
        int p2 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[y]); R = max(see[a],see[y]);
        query(1,1,dfs_clock);
        int p3 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[x]); R = max(see[b],see[x]);
        query(1,1,dfs_clock);
        int p4 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[y]); R = max(see[b],see[y]);
        query(1,1,dfs_clock);
        int p5 = ans.pos;
        int dd[10];
        int dax = dist[a]+dist[x]-2*dist[p2];
        int day = dist[a]+dist[y]-2*dist[p3];
        int dbx = dist[b]+dist[x]-2*dist[p4];
        int dby = dist[b]+dist[y]-2*dist[p5];
        int dxy = dist[x]+dist[y]-2*dist[p0];
        int dab = dist[a]+dist[b]-2*dist[p1];
        dd[1] = dab; dd[2] = dax+dby+dxy; dd[3] = dax+dby+1;
        dd[4] = day+dbx+dxy; dd[5] = day+dbx+1;
        int flag = 0;
        for(int i = 1; i <= 5; i++)
        {
            if(k >= dd[i]&&k%2==dd[i]%2)
                flag = 1;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
            dfs_clock++;
            lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
        }
    }
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
        return;
    }
    int mid = left+(right-left)/2;
    if(p <= mid)
        update(o*2,left,mid);
    else if(p > mid)
        update(o*2+1,mid+1,right);
    if(tree[o*2].d <= tree[o*2].d)
        tree[o] = tree[o*2];
    else
        tree[o] = tree[o*2+1];
}

int L,R,ans,mi;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < mi)
        {
            mi = tree[o].d;
            ans = tree[o].pos;
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int mydist(int a,int b)
{
    L = min(see[a],see[b]); R = max(see[a],see[b]);
    ans = 0; mi = 1e9;
    query(1,1,dfs_clock);
    int re = dist[a]+dist[b]-2*dist[ans];
    return re;
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        int dax = mydist(a,x),day = mydist(a,y),dxy = mydist(x,y);
        int dbx = mydist(b,x),dby = mydist(b,y),dab = mydist(a,b);
        int dd[10];
        dd[1] = dab; dd[2] = dax+dby+1; dd[3] = day+dbx+1;
        int flag = 0;
        for(int i = 1; i <= 3; i++)
        {
            if(k >= dd[i]&&k%2==dd[i]%2)
                flag = 1;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
            dfs_clock++;
            lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
        }
    }
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
        return;
    }
    int mid = left+(right-left)/2;
    if(p <= mid)
        update(o*2,left,mid);
    else if(p > mid)
        update(o*2+1,mid+1,right);
    if(tree[o*2].d <= tree[o*2].d)
        tree[o] = tree[o*2];
    else
        tree[o] = tree[o*2+1];
}

int L,R,ans,mi;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < ans.d)
        {
            mi = tree[o].d;
            ans = tree[o].pos;
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int mydist(int a,int b)
{
    L = min(see[a],see[b]); R = max(see[a],see[b]);
    ans = 0; mi = 1e9;
    query(1,1,dfs_clock);
    int re = dist[a]+dist[b]-2*dist[ans];
    return re;
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        int dax = mydist(a,x),day = mydist(a,y),dxy = mydist(x,y);
        int dbx = mydist(b,x),dby = mydist(b,y),dab = mydist(a,b);
        int dd[10];
        dd[1] = dab; dd[2] = dax+dby+1; dd[3] = day+dbx+1;
        int flag = 0;
        for(int i = 1; i <= 3; i++)
        {
            if(k >= dd[i]&&k%2==dd[i]%2)
                flag = 1;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
        }
    }
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
    }
    else
    {
        int mid = left+(right-left)/2;
        if(p <= mid)
            update(o*2,left,mid);
        else if(p > mid)
            update(o*2+1,mid+1,right);
        if(tree[o*2].d <= tree[o*2].d)
            tree[o] = tree[o*2];
        else
            tree[o] = tree[o*2+1];
    }
}

int L,R;
node ans;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < ans.d)
        {
            ans = tree[o];
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        ans.d = 1e9; L = min(see[x],see[y]); R = max(see[x],see[y]);
        query(1,1,dfs_clock);
        int p0 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[b]); R = max(see[a],see[b]);
        query(1,1,dfs_clock);
        int p1 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[x]); R = max(see[a],see[x]);
        query(1,1,dfs_clock);
        int p2 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[y]); R = max(see[a],see[y]);
        query(1,1,dfs_clock);
        int p3 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[x]); R = max(see[b],see[x]);
        query(1,1,dfs_clock);
        int p4 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[y]); R = max(see[b],see[y]);
        query(1,1,dfs_clock);
        int p5 = ans.pos;
        int dxx = dist[a]+dist[b]+2*dist[x]-2*dist[p2]-2*dist[p4];
        int dyy = dist[a]+dist[b]+2*dist[y]-2*dist[p3]-2*dist[p5];
        int dxy = 1e9;
        dxy = min(dxy,dist[a]+dist[b]+dist[x]+dist[y]-2*dist[p2]-2*dist[p3]+1);
        dxy = min(dxy,dist[a]+dist[b]+dist[x]+dist[y]-2*dist[p4]-2*dist[p5]+1);
        int dab = dist[a]+dist[b]-2*dist[p1];
        int dd = 1e9;
        dd = min(dd,dab); dd = min(dd,dxy); dd = min(dd,dxx); dd = min(dd,dyy);
        if(k < dd)
        {
            cout<<"NO"<<endl;
        }
        else if(k >= dd)
        {
            int d1 = dist[x]+dist[y]-2*dist[p0]+1;
            if(d1%2==1)
                cout<<"YES"<<endl;
            else
            {
                if(k%2==dd%2)
                    cout<<"YES"<<endl;
                else
                    cout<<"NO"<<endl;
            }
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
            dfs_clock++;
            lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
        }
    }
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
        return;
    }
    int mid = left+(right-left)/2;
    if(p <= mid)
        update(o*2,left,mid);
    else if(p > mid)
        update(o*2+1,mid+1,right);
    if(tree[o*2].d <= tree[o*2+1].d)
        tree[o] = tree[o*2];
    else
        tree[o] = tree[o*2+1];
}

int L,R,ans,mi;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < mi)
        {
            mi = tree[o].d;
            ans = tree[o].pos;
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int mydist(int a,int b)
{
    L = min(see[a],see[b]); R = max(see[a],see[b]);
    ans = 0; mi = 1e9;
    query(1,1,dfs_clock);
    int re = dist[a]+dist[b]-2*dist[ans];
    return re;
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        int dax = mydist(a,x),day = mydist(a,y),dxy = mydist(x,y);
        int dbx = mydist(b,x),dby = mydist(b,y),dab = mydist(a,b);
        int dd[10];
        dd[1] = dab; dd[2] = dax+dby+1; dd[3] = day+dbx+1;
        int flag = 0;
        for(int i = 1; i <= 3; i++)
        {
            if(k >= dd[i]&&(k%2==dd[i]%2))
                flag = 1;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
        }
    }
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
    }
    else
    {
        int mid = left+(right-left)/2;
        if(p <= mid)
            update(o*2,left,mid);
        else if(p > mid)
            update(o*2+1,mid+1,right);
        if(tree[o*2].d <= tree[o*2].d)
            tree[o] = tree[o*2];
        else
            tree[o] = tree[o*2+1];
    }
}

int L,R;
node ans;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < ans.d)
        {
            ans = tree[o];
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        ans.d = 1e9; L = min(see[x],see[y]); R = max(see[x],see[y]);
        query(1,1,dfs_clock);
        int z = ans.pos;
        int d1 = dist[x]+dist[y]-2*dist[z];
        //cout<<d1<<endl;
        ans.d = 1e9; L = min(see[a],see[b]); R = max(see[a],see[b]);
        query(1,1,dfs_clock);
        int p1 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[x]); R = max(see[a],see[x]);
        query(1,1,dfs_clock);
        int p2 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[y]); R = max(see[a],see[y]);
        query(1,1,dfs_clock);
        int p3 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[x]); R = max(see[b],see[x]);
        query(1,1,dfs_clock);
        int p4 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[y]); R = max(see[b],see[y]);
        query(1,1,dfs_clock);
        int p5 = ans.pos;
        int d2 = dist[a]+dist[b]-2*dist[p1];
        int d3 = dist[a]+dist[x]-2*dist[p2]+dist[b]+dist[y]-2*dist[p5];
        int d4 = dist[b]+dist[x]-2*dist[p4]+dist[a]+dist[y]-2*dist[p3];
        int dd = min(d2,min(d3,d4)+1);
        //cout<<k<<' '<<dd<<endl;
        if(k < dd)
        {
            cout<<"NO"<<endl;
        }
        else if(k >= dd)
        {
            if(d1%2==0)
                cout<<"YES"<<endl;
            else
            {
                if(k%2==dd%2)
                    cout<<"YES"<<endl;
                else
                    cout<<"NO"<<endl;
            }
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

struct node
{
    int d,pos;
};
int dist[100010],dfs_clock,vis[100010];
vector<int> graph[100010];
node lca[200020],tree[2*800080];
int see[100010];

void dfs(int now,int d0)
{
    vis[now] = 1;
    dist[now] = d0;
    dfs_clock++;
    lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
    see[now] = dfs_clock;
    int u = graph[now].size();
    for(int i = 0; i < u; i++)
    {
        int v = graph[now][i];
        if(vis[v]==0)
        {
            dfs(v,d0+1);
            dfs_clock++;
            lca[dfs_clock].d = d0; lca[dfs_clock].pos = now;
        }
    }
}

node in;
int p;
void update(int o,int left,int right)
{
    if(left==right)
    {
        tree[o] = in;
    }
    else
    {
        int mid = left+(right-left)/2;
        if(p <= mid)
            update(o*2,left,mid);
        else if(p > mid)
            update(o*2+1,mid+1,right);
        if(tree[o*2].d <= tree[o*2].d)
            tree[o] = tree[o*2];
        else
            tree[o] = tree[o*2+1];
    }
}

int L,R;
node ans;
void query(int o,int left,int right)
{
    if(L <= left&&R >= right)
    {
        if(tree[o].d < ans.d)
        {
            ans = tree[o];
        }
    }
    else
    {
        int mid = left+(right-left)/2;
        if(L <= mid)
            query(o*2,left,mid);
        if(R > mid)
            query(o*2+1,mid+1,right);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 1; i <= n-1; i++)
    {
        int from,to;
        cin>>from>>to;
        graph[from].push_back(to);
        graph[to].push_back(from);
    }
    dfs(1,0);
    for(int i = 1; i <= dfs_clock; i++)
    {
        p = i; in = lca[i];
        update(1,1,dfs_clock);
    }
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int x,y,a,b,k;
        cin>>x>>y>>a>>b>>k;
        ans.d = 1e9; L = min(see[x],see[y]); R = max(see[x],see[y]);
        query(1,1,dfs_clock);
        int p0 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[b]); R = max(see[a],see[b]);
        query(1,1,dfs_clock);
        int p1 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[x]); R = max(see[a],see[x]);
        query(1,1,dfs_clock);
        int p2 = ans.pos;
        ans.d = 1e9; L = min(see[a],see[y]); R = max(see[a],see[y]);
        query(1,1,dfs_clock);
        int p3 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[x]); R = max(see[b],see[x]);
        query(1,1,dfs_clock);
        int p4 = ans.pos;
        ans.d = 1e9; L = min(see[b],see[y]); R = max(see[b],see[y]);
        query(1,1,dfs_clock);
        int p5 = ans.pos;
        int dd[10];
        int dax = dist[a]+dist[x]-2*dist[p2];
        int day = dist[a]+dist[y]-2*dist[p3];
        int dbx = dist[b]+dist[x]-2*dist[p4];
        int dby = dist[b]+dist[y]-2*dist[p5];
        int dxy = dist[x]+dist[y]-2*dist[p0];
        int dab = dist[a]+dist[b]-2*dist[p1];
        dd[1] = dab; dd[2] = dax+dby+dxy; dd[3] = dax+dby+1;
        dd[4] = day+dbx+dxy; dd[5] = day+dbx+1;
        int flag = 0;
        for(int i = 1; i <= 5; i++)
        {
            if(k >= dd[i]&&k%2==dd[i]%2)
                flag = 1;
        }
        if(flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> aray[100001];
vector<int> euler;
int dist[100001];
void dfs(int root, int count)
{
	dist[root] = count;
	euler.push_back(root);
	for(int i=0;i<aray[root].size();i++)
	{
		int val = aray[root][i];
		if(dist[val] == -1)
		{
			dfs(val, count+1);
			euler.push_back(root);
		}
	}
	return ;
}
bool valid(int a, int b)
{
	if(a > b)
		return false;
	if(((a-b)%2) == 0)
		return true;
	return false;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int t = n-1, x, y;
	while(t--)
	{
		cin>>x>>y;
		aray[x].push_back(y);
		aray[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		dist[i] = -1;
	dfs(1, 0);
	int first[n+1];
	for(int i=euler.size()-1;i>=0;i--)
		first[euler[i]] = i;
	int m = euler.size();
	int s = sqrt(m);
	int box = ceil((double)m/s);
	int num[box];
	for(int i=0;i<box;i++)
	{
		num[i] = 1000000000;
		for(int j=i*s;j<min(m, (i+1)*s);j++)
			num[i] = min(num[i], dist[euler[j]]);
	}
	int q;
	cin>>q;
	while(q--)
	{
		int arr[4], k;
		for(int i=0;i<4;i++)
			cin>>arr[i];
		cin>>k;
		int count = 0;
		bool ans = false;
		vector<int> dia;
		for(int i=0;i<2;i++)
		{
			for(int j=2;j<4;j++)
			{
				int fir = first[arr[i]], sec = first[arr[j]];
				int temp = min(fir, sec), tmep = max(fir, sec);
				fir = temp;
				sec = tmep;
				int bfir = fir/s, bsec = sec/s;
				int val = 100000000;
				if(bfir == bsec)
				{
					for(int i=fir;i<=sec;i++)
						val = min(val, dist[euler[i]]);
				}
				else
				{
					for(int i=bfir+1;i<bsec;i++)
						val = min(val, num[i]);
					for(int i=fir;i<bfir*s+s;i++)
						val = min(val, dist[euler[i]]);
					for(int i=s*bsec;i<=sec;i++)
						val = min(val, dist[euler[i]]);
				}
				int distance = dist[arr[i]]+dist[arr[j]]-2*val;
				dia.push_back(distance);
			}
		}
		if(valid(dia[0]+dia[3]+1, k))
			ans = true;
		if(valid(dia[1]+dia[2]+1, k))
			ans = true;
		int fir = first[arr[2]], sec = first[arr[3]];
		int temp = min(fir, sec), tmep = max(fir, sec);
		fir = temp;
		sec = tmep;
		int bfir = fir/s, bsec = sec/s;
		int val = 10000000;
		if(bfir == bsec)
		{
			for(int i=fir;i<=sec;i++)
				val = min(val, dist[euler[i]]);
		}
		else
		{
			for(int i=bfir+1;i<bsec;i++)
				val = min(val, num[i]);
			for(int i=fir;i<bfir*s+s;i++)
				val = min(val, dist[euler[i]]);
			for(int i=s*bsec;i<=sec;i++)
				val = min(val, dist[euler[i]]);
		}
		int distance = dist[arr[2]]+dist[arr[3]]-2*val;
		if(valid(distance, k))
			ans = true;
		if((distance<=k) && ((distance-k)%2) == 0)
			ans = true;
		if(ans)
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
	return 0;
}