#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 19, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if((k - dist) % 2 == 0 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int xx = d(x, a) + d(y, b) + 1;
			int yy = d(y, a) + d(x, b) + 1;
			int zz = d(x, a) + 2 + d(y, a);
			int pp = d(x, b) + 2 + d(y, b);
			if((k - xx) % 2 == 0 && xx <= k){
				cout << "YES" << endl;
			}
			else if((k - yy) % 2 == 0 && yy <= k){
				cout << "YES" << endl;
			}
			else if((k - zz) % 2 == 0 && zz <= k){
				cout << "YES" << endl;
			}
			else if((k - pp) % 2 == 0 && pp <= k){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, z;
		cin >> x >> y >> a >> b >> z;
		int dist = d(a, b);
		if(dist % 2 == z % 2 && dist >= z){
			cout << "YES" << endl;
		}
		else{
			int dx = d(x, a) + d(y, b) + 1;
			int dy = d(y, a) + d(x, b) + 1;
			if(dx % 2 == z % 2 && dx <= z){
				cout << "YES" << endl;
			}
			else if(dy % 2 == z % 2 && dy <= z){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 19, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if((k - dist) % 2 == 0 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int xx = d(x, a) + d(y, b) + 1;
			int yy = d(y, a) + d(x, b) + 1;
			int zz = 2 * d(x, a) + 2 + dist;
			int pp = 2 * d(x, b) + 2 + dist;
			if((k - xx) % 2 == 0 && xx <= k){
				cout << "YES" << endl;
			}
			else if((k - yy) % 2 == 0 && yy <= k){
				cout << "YES" << endl;
			}
			else if((k - zz) % 2 == 0 && zz <= k){
				cout << "YES" << endl;
			}
			else if((k - pp) % 2 == 0 && pp <= k){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if((k - dist) % 2 == 0 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int xx = d(x, a) + d(y, b) + 1;
			int yy = d(y, a) + d(x, b) + 1;
			int zz = xx * 2 + dist;
			int pp = yy * 2 + dist;
			if((k - xx) % 2 == 0 && xx <= k){
				cout << "YES" << endl;
			}
			else if((k - yy) % 2 == 0 && yy <= k){
				cout << "YES" << endl;
			}
			else if((k - zz) % 2 == 0 && zz <= k){
				cout << "YES" << endl;
			}
			else if((k - pp) % 2 == 0 && pp <= k){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, z;
		cin >> x >> y >> a >> b >> z;
		int dist = d(a, b);
		int dist2 = min(d(x, a) + d(y, b), d(x, b) + d(y, a)) + 1;
		if((z - dist) >= 0 && z % dist == 0){
			cout << "YES" << endl;
		}
		else if((z - dist2) >= 0 && z % dist2 == 0){
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if(dist % 2 == k % 2 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int dx = d(x, a) + d(y, b) + 1;
			int dy = d(y, a) + d(x, b) + 1;
			if((k % dx) % 2 == 0 || (k % dy) % 2 == 0)
				cout << "YES" << endl;
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, z;
		cin >> x >> y >> a >> b >> z;
		int dist = d(a, b);
		if(dist % 2 == z % 2 && dist <= z){
			cout << "YES" << endl;
		}
		else{
			int dx = d(x, a) + d(y, b) + 1;
			int dy = d(y, a) + d(x, b) + 1;
			if(dx % 2 == z % 2 && dx <= z){
				cout << "YES" << endl;
			}
			else if(dy % 2 == z % 2 && dy <= z){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if(dist % 2 == k % 2 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int xx = d(x, a) + d(y, b) + 1;
			int yy = d(y, a) + d(x, b) + 1;
			if((k - xx) % 2 == 0 && xx <= k){
				cout << "YES" << endl;
			}
			else if((k - yy) % 2 == 0 && yy <= k){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 19, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if((k - dist) % 2 == 0 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int xx = d(x, a) + d(y, b) + 1;
			int yy = d(y, a) + d(x, b) + 1;
			int zz = d(x, a) + 2 + d(x, b);
			int pp = d(y, a) + 2 + d(y, b);
			if((k - xx) % 2 == 0 && xx <= k){
				cout << "YES" << endl;
			}
			else if((k - yy) % 2 == 0 && yy <= k){
				cout << "YES" << endl;
			}
			else if((k - zz) % 2 == 0 && zz <= k){
				cout << "YES" << endl;
			}
			else if((k - pp) % 2 == 0 && pp <= k){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 18, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);
		if(dist % 2 == k % 2 && dist <= k){
			cout << "YES" << endl;
		}
		else{
			int dx = d(x, a) + d(y, b) + 1;
			int dy = d(y, a) + d(x, b) + 1;
			if(k % dx == 0 || k % dx == d(a, b)) cout << "YES" << endl;
			else if(k % dy == 0 || k % dy == d(a, b)) cout << "YES" << endl;
			else cout << "NO" << endl;
		}

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool check(vector<pair<int,int>> x) {
	const int n = x.size();
	map< pair<int,int>, bool > was;
	int mini = x[0].first, maxi = x[0].first;
	for  (int i = 0;i < n;i ++) {
		mini = min(mini, x[i].first);
		maxi = max(maxi, x[i].first);
		was[x[i]] = true;
	}
	for (int i = 0;i < n;i ++) {
		double cur = maxi - x[i].first;
		double p = mini + cur;
		double y = (x[i].second);
		cout << cur << " " << y << "\n";
		if (was[{p, y}] == 0) return false;
	}
	return true;
}

bool test() {
	int x [] = {1, 3};
	int y [] = {10, 10};
	vector<pair<int,int>> pass;
	for (int i = 0;i < 2;i ++) {
		pair<int,int> cur = {x[i], y[i]};
		pass.push_back(cur);
	}
	cout << check(pass);
}

int main() {
	test();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int l = 19, h[N];
vector<int> g[N];
int tin[N], tout[N];
int timer;
int up[N][20];

void dfs (int v, int p = 0) {
	h[v] = h[p] + 1;
	tin[v] = ++timer;
	up[v][0] = p;
	for (int i=1; i<=l; ++i)
		up[v][i] = up[up[v][i-1]][i-1];
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (to != p)
			dfs (to, v);
	}
	tout[v] = ++timer;
}

bool upper (int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
	if (upper (a, b))  return a;
	if (upper (b, a))  return b;
	for (int i=l; i>=0; --i)
		if (! upper (up[a][i], b))
			a = up[a][i];
	return up[a][0];
}

int d(int x, int y){
	return h[x] + h[y] - 2 * h[lca(x, y)];
}
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i){
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1);
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int x, y, a, b, k;
		cin >> x >> y >> a >> b >> k;
		int dist = d(a, b);

			int xx = d(x, a) + d(y, b) + 1;
			int yy = d(y, a) + d(x, b) + 1;
			int zz = d(y, a) + d(x, b) + 3;
			int pp = d(y, a) + d(x, b) + 3;
			if((k - xx) % 2 == 0 && xx <= k){
				cout << "YES" << endl;
			}
			else if((k - yy) % 2 == 0 && yy <= k){
				cout << "YES" << endl;
			}
			else if((k - zz) % 2 == 0 && zz <= k){
				cout << "YES" << endl;
			}
			else if((k - pp) % 2 == 0 && pp <= k){
				cout << "YES" << endl;
			}
			else cout << "NO" << endl;

	}
}

int main()
{
    Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],cnt;
void init(){memset(h,0,sizeof h);cnt=0;}///初始化,如没有多测可以不加
void add(int x,int y){to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;}
void dfs1(int x){
	sz[x]=1;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]){
		fa[to[i]]=x;dep[to[i]]=dep[x]+1;
        dfs1(to[i]);sz[x]+=sz[to[i]];
	}
}
void dfs2(int x,int c){
	int k=-1;bl[x]=c;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&sz[to[i]]>sz[k])
	k=to[i];
	if(k==-1)return;dfs2(k,c);
    for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&to[i]!=k)dfs2(to[i],to[i]);
}
int lca(int x,int y){
	for(;bl[x]!=bl[y];x=fa[bl[x]]){
		if(dep[x]<dep[y])swap(x,y);
	}
	return dep[x]<dep[y]?x:y;
}
int dist(int x,int y){
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int n,m;
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        //--x,--y;
        add(x,y),add(y,x);
    }
    dfs1(1);dfs2(1,1);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        //--a,--b,--x,--y;
        int l=dist(a,b);
        cout<<l<<endl;
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],cnt;
void init(){memset(h,0,sizeof h);cnt=0;}
void add(int x,int y){to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;}
void dfs1(int x){
	sz[x]=1;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]){
		fa[to[i]]=x;dep[to[i]]=dep[x]+1;
        dfs1(to[i]);sz[x]+=sz[to[i]];
	}
}
void dfs2(int x,int c){
	int k=0;bl[x]=c;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&sz[to[i]]>sz[k])k=to[i];
	if(!k)return;dfs2(k,c);
    for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&to[i]!=k)dfs2(to[i],to[i]);
}
int lca(int x,int y){
	for(;bl[x]!=bl[y];x=fa[bl[x]]){
		if(dep[x]<dep[y])swap(x,y);
	}
	return dep[x]<dep[y]?x:y;
}
int dist(int x,int y){
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int n,m;
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        //--x,--y;
        add(x,y),add(y,x);
    }
    dfs1(1);dfs2(1,1);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

const int N=500010;

int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],q[N],tail;

int n,m,s,cnt;
inline void add(int x,int y)
{
    to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;
}
void dfs1(int x)
{
    int i;
    sz[x]=1;
    for(i=h[x];i;i=nxt[i])
    {
        if(to[i]!=fa[x])
        {
            fa[to[i]]=x;
            dep[to[i]]=dep[x]+1;
            dfs1(to[i]);
            sz[x]+=sz[to[i]];
        }
    }
}
void dfs2(int x,int c)
{
    int i,k=0;
    bl[x]=c;
    q[++tail]=x;
    for(i=h[x];i;i=nxt[i])
       if(to[i]!=fa[x]&&sz[to[i]]>sz[k])
         k=to[i];
    if(k)
    {
        dfs2(k,c);
        for(i=h[x];i;i=nxt[i])
        if(to[i]!=fa[x]&&to[i]!=k)
        dfs2(to[i],to[i]);
    }
}
int lca(int x,int y)
{
    while(bl[x]!=bl[y])
    {
        if(dep[bl[x]]<dep[bl[y]])swap(x,y);
        x=fa[bl[x]];
    }
    if(dep[x]<dep[y])return x;
    return y;
}
int dist(int x,int y){
     return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        --x,--y;
        add(x,y),add(y,x);
    }
    dfs1(0);dfs2(0,0);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        --a,--b,--x,--y;
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],cnt;
void init(){memset(h,0,sizeof h);cnt=0;}
void add(int x,int y){to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;}
void dfs1(int x){
	sz[x]=1;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]){
		fa[to[i]]=x;dep[to[i]]=dep[x]+1;
        dfs1(to[i]);sz[x]+=sz[to[i]];
	}
}
void dfs2(int x,int c){
	int k=0;bl[x]=c;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&sz[to[i]]>sz[k])k=to[i];
	if(!k)return;dfs2(k,c);
    for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&to[i]!=k)dfs2(to[i],to[i]);
}
int lca(int x,int y){
	while(bl[x]!=bl[y])
    {
        if(dep[bl[x]]<dep[bl[y]])swap(x,y);
        x=fa[bl[x]];
    }
    if(dep[x]<dep[y])return x;
    return y;
}
int dist(int x,int y){
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int n,m;
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    dfs1(1);dfs2(1,1);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

const int N=300010;

int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],q[N],tail;

int n,m,s,cnt;
inline void add(int x,int y)
{
    to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;
}
void dfs1(int x)
{
    int i;
    sz[x]=1;
    for(i=h[x];i;i=nxt[i])
    {
        if(to[i]!=fa[x])
        {
            fa[to[i]]=x;
            dep[to[i]]=dep[x]+1;
            dfs1(to[i]);
            sz[x]+=sz[to[i]];
        }
    }
}
void dfs2(int x,int c)
{
    int i,k=0;
    bl[x]=c;
    //q[++tail]=x;
    for(i=h[x];i;i=nxt[i])
       if(to[i]!=fa[x]&&sz[to[i]]>sz[k])
         k=to[i];
    if(k)
    {
        dfs2(k,c);
        for(i=h[x];i;i=nxt[i])
        if(to[i]!=fa[x]&&to[i]!=k)
        dfs2(to[i],to[i]);
    }
}
int lca(int x,int y)
{
    while(bl[x]!=bl[y])
    {
        if(dep[bl[x]]<dep[bl[y]])swap(x,y);
        x=fa[bl[x]];
    }
    if(dep[x]<dep[y])return x;
    return y;
}
int dist(int x,int y){
     return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        --x,--y;
        add(x,y),add(y,x);
    }
    dfs1(0);dfs2(0,0);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        --a,--b,--x,--y;
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

const int N=300010;

int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N];

int n,m,s,cnt;
inline void add(int x,int y)
{
    to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;
}
void dfs1(int x)
{
    int i;
    sz[x]=1;
    for(i=h[x];i;i=nxt[i])
    {
        if(to[i]!=fa[x])
        {
            fa[to[i]]=x;
            dep[to[i]]=dep[x]+1;
            dfs1(to[i]);
            sz[x]+=sz[to[i]];
        }
    }
}
void dfs2(int x,int c)
{
    int i,k=0;
    bl[x]=c;
    for(i=h[x];i;i=nxt[i])
       if(to[i]!=fa[x]&&sz[to[i]]>sz[k])
         k=to[i];
    if(k)
    {
        dfs2(k,c);
        for(i=h[x];i;i=nxt[i])
        if(to[i]!=fa[x]&&to[i]!=k)
        dfs2(to[i],to[i]);
    }
}
int lca(int x,int y)
{
    while(bl[x]!=bl[y])
    {
        if(dep[bl[x]]<dep[bl[y]])swap(x,y);
        x=fa[bl[x]];
    }
    if(dep[x]<dep[y])return x;
    return y;
}
int dist(int x,int y){
     return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        //--x,--y;
        add(x,y),add(y,x);
    }
    dfs1(1);dfs2(1,1);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        //--a,--b,--x,--y;
        int l=dist(a,b);
        //cout<<l<<endl;
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

const int N=500010;

int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],q[N],tail;

int n,m,s,cnt;
inline void add(int x,int y)
{
    to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;
}
void dfs1(int x)
{
    int i;
    sz[x]=1;
    for(i=h[x];i;i=nxt[i])
    {
        if(to[i]!=fa[x])
        {
            fa[to[i]]=x;
            dep[to[i]]=dep[x]+1;
            dfs1(to[i]);
            sz[x]+=sz[to[i]];
        }
    }
}
void dfs2(int x,int c)
{
    int i,k=0;
    bl[x]=c;
    q[++tail]=x;
    for(i=h[x];i;i=nxt[i])
       if(to[i]!=fa[x]&&sz[to[i]]>sz[k])
         k=to[i];
    if(k)
    {
        dfs2(k,c);
        for(i=h[x];i;i=nxt[i])
        if(to[i]!=fa[x]&&to[i]!=k)
        dfs2(to[i],to[i]);
    }
}
int lca(int x,int y)
{
    while(bl[x]!=bl[y])
    {
        if(dep[bl[x]]<dep[bl[y]])swap(x,y);
        x=fa[bl[x]];
    }
    if(dep[x]<dep[y])return x;
    return y;
}
int dist(int x,int y){
     return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        --x,--y;
        add(x,y),add(y,x);
    }
    fa[0]=-1;
    dfs1(0);dfs2(0,0);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        --a,--b,--x,--y;
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],cnt;
void init(){memset(h,0,sizeof h);cnt=0;}
void add(int x,int y){to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;}
void dfs1(int x){
	sz[x]=1;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]){
		fa[to[i]]=x;dep[to[i]]=dep[x]+1;
        dfs1(to[i]);sz[x]+=sz[to[i]];
	}
}
void dfs2(int x,int c){
	int k=0;bl[x]=c;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&sz[to[i]]>sz[k])k=to[i];
	if(!k)return;dfs2(k,c);
    for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&to[i]!=k)dfs2(to[i],to[i]);
}
int lca(int x,int y){
	while(bl[x]!=bl[y])
    {
        if(dep[bl[x]]<dep[bl[y]])swap(x,y);x=fa[bl[x]];
    }
    return dep[x]<dep[y]?x:y;
}
int dist(int x,int y){
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int n,m;
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    dfs1(1);dfs2(1,1);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300010;
int h[N],nxt[N<<1],to[N<<1],sz[N],fa[N],dep[N],bl[N],cnt;
void init(){memset(h,0,sizeof h);cnt=0;}
void add(int x,int y){to[++cnt]=y;nxt[cnt]=h[x];h[x]=cnt;}
void dfs1(int x){
	sz[x]=1;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]){
		fa[to[i]]=x;dep[to[i]]=dep[x]+1;
        dfs1(to[i]);sz[x]+=sz[to[i]];
	}
}
void dfs2(int x,int c){
	int k=-1;bl[x]=c;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&sz[to[i]]>sz[k])k=to[i];
	if(k==-1)return;dfs2(k,c);
    for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]&&to[i]!=k)dfs2(to[i],to[i]);
}
int lca(int x,int y){
	for(;bl[x]!=bl[y];x=fa[bl[x]]){
		if(dep[x]<dep[y])swap(x,y);
	}
	return dep[x]<dep[y]?x:y;
}
int dist(int x,int y){
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
int n,m;
int main()
{
    scanf("%d",&n);
    for(int x,y,i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        //--x,--y;
        add(x,y),add(y,x);
    }
    dfs1(1);dfs2(1,1);
    scanf("%d",&m);
    while(m--)
    {
        int a,b,k,x,y;
        scanf("%d%d%d%d%d",&x,&y,&a,&b,&k);
        int l=dist(a,b);
        int f=min(dist(a,x)+dist(b,y),dist(a,y)+dist(b,x))+1;
        if((k>=l&&(k-l)%2==0)||(k>=f&&(k-f)%2==0))puts("YES");
        else puts("NO");
    }
}


#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

class Tree{
    private:
        vector<vector<int>> a;
        vector<int> first_pos;
        vector<pair<int, int>> node_level;
        vector<vector<int>> rmq;
        vector<int> my_log2;
        vector<int> d;
        int root;
        int n;

        void bfs(const int& src){
            fill(d.begin(), d.end(), -1);
            d[src] = 0;

            queue<int> q;
            q.push(src);

            while(!q.empty()){
                int x = q.front();
                q.pop();

                for(int y: a[x]){
                    if(d[y] == -1){
                        d[y] = 1 + d[x];
                        q.push(y);
                    }
                }
            }
        }

        void dfs_euler(int x, int level){
            node_level.push_back({x, level});
            if(first_pos[x] == -1){
                first_pos[x] = node_level.size();
            }

            for(int y: a[x]){
                if(first_pos[y] == -1){
                    dfs_euler(y, level + 1);
                    node_level.push_back({x, level});
                }
            }
        }

        void build_rmq(){
            int p = 1;
            int cur_log = 1;

            my_log2.resize(node_level.size() + 1, 0);
            for(int i = 2; i <= node_level.size(); ++i){
                my_log2[i] = 1 + my_log2[i / 2];
            }

            rmq.resize(node_level.size() + 1,
                       vector<int>(my_log2[node_level.size()] + 1, n + 1));
            for(int i = 1; i <= rmq.size() - 1; ++i){
                rmq[i][0] = i - 1;
            }

            for(int j = 1; j <= rmq[0].size() - 1; ++j){
                int range_len = (1 << j);
                for(int i = 1; i <= rmq.size() - range_len; ++i){
                    int l_idx = rmq[i][j - 1];
                    int r_idx = rmq[i + range_len / 2][j - 1];
                    if(node_level[l_idx].second < node_level[r_idx].second){
                        rmq[i][j] = l_idx;
                    }else{
                        rmq[i][j] = r_idx;
                    }
                }
            }
        }

    public:
        Tree(vector<vector<int>> a, int n){
            this->a = a;
            this->n = n;
            this->first_pos.resize(n + 1, -1);
            this->root = 1;
            this->d.resize(n + 1);

            int level = 0;
            dfs_euler(root, level);
            build_rmq();
            bfs(root);
        }

        int get_lca(int x, int y){
            int start_idx = min(first_pos[x], first_pos[y]);
            int end_idx = max(first_pos[x], first_pos[y]);
            int range_len = end_idx - start_idx + 1;

            int lca_x_y = -1;
            int j = my_log2[range_len];
            int l_idx = rmq[start_idx][j];
            int r_idx = rmq[end_idx - (1 << j) + 1][j];

            if(node_level[l_idx].second < node_level[r_idx].second){
                lca_x_y = node_level[l_idx].first;
            }else{
                lca_x_y = node_level[r_idx].first;
            }

            return lca_x_y;
        }

        int get_dist(int x, int y){
            int lca_x_y = get_lca(x, y);
            return d[x] + d[y] - 2 * d[lca_x_y];
        }
};

bool is_ok(const int& dist, const int& k){
    return (dist <= k) && ((k - dist) % 2 == 0);
}

int main(int argc, char** argv){
    #ifndef ONLINE_JUDGE
        freopen((string(argv[1]) + ".in").c_str(), "r", stdin);
        freopen((string(argv[1]) + ".out").c_str(), "w", stdout);
    #endif

    int n;
    scanf("%d\n", &n);

    vector<vector<int>> a(n + 1, vector<int>());
    int x, y;
    for(int i = 1; i <= n - 1; ++i){
        scanf("%d %d\n", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }

    Tree tree(a, n);

    int q, src, dest, k;
    scanf("%d\n", &q);

    for(; q > 0; --q){
        scanf("%d %d %d %d %d\n", &x, &y, &src, &dest, &k);

        int dist_src_dest = tree.get_dist(src, dest);
        int dist_src_x = tree.get_dist(src, x);
        int dist_src_y = tree.get_dist(src, y);
        int dist_dest_x = tree.get_dist(dest, x);
        int dist_dest_y = tree.get_dist(dest, y);
        int dist_x_y = 1; // because we add edge (x, y)

        int d1 = dist_src_dest;
        int d2 = dist_src_x + dist_x_y + dist_dest_y;
        int d3 = dist_src_y + dist_x_y + dist_dest_x;

        bool is_ok_1 = is_ok(d1, k);
        bool is_ok_2 = is_ok(d2, k);
        bool is_ok_3 = is_ok(d3, k);

        string ans = (is_ok_1 || is_ok_2 || is_ok_3 ? "YES" : "NO");

        printf("%s\n", ans.c_str());
    }

    return 0;
}


#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

class Tree{
    private:
        vector<vector<int>> a;
        vector<int> first_pos;
        vector<pair<int, int>> node_level;
        vector<vector<int>> rmq;
        vector<int> my_log2;
        vector<int> d;
        int root;
        int n;

        void bfs(const int& src){
            fill(d.begin(), d.end(), -1);
            d[src] = 0;

            queue<int> q;
            q.push(src);

            while(!q.empty()){
                int x = q.front();
                q.pop();

                for(int y: a[x]){
                    if(d[y] == -1){
                        d[y] = 1 + d[x];
                        q.push(y);
                    }
                }
            }
        }

        void dfs_euler(int x, int level){
            node_level.push_back({x, level});
            if(first_pos[x] == -1){
                first_pos[x] = node_level.size();
            }

            for(int y: a[x]){
                if(first_pos[y] == -1){
                    dfs_euler(y, level + 1);
                    node_level.push_back({x, level});
                }
            }
        }

        void build_rmq(){
            my_log2.resize(node_level.size() + 1, 0);
            for(int i = 2; i <= node_level.size(); ++i){
                my_log2[i] = 1 + my_log2[i / 2];
            }

            rmq.resize(node_level.size() + 1,
                       vector<int>(my_log2[node_level.size()] + 1, n + 1));

            for(int i = 1; i <= rmq.size() - 1; ++i){
                rmq[i][0] = i - 1;
            }

            for(int j = 1; j <= rmq[0].size() - 1; ++j){
                int range_len = (1 << j);
                for(int i = 1; i <= rmq.size() - range_len; ++i){
                    int l_idx = rmq[i][j - 1];
                    int r_idx = rmq[i + range_len / 2][j - 1];
                    if(node_level[l_idx].second < node_level[r_idx].second){
                        rmq[i][j] = l_idx;
                    }else{
                        rmq[i][j] = r_idx;
                    }
                }
            }
        }

    public:
        Tree(vector<vector<int>> a, int n){
            this->a = a;
            this->n = n;
            this->first_pos.resize(n + 1, -1);
            this->root = 1;
            this->d.resize(n + 1);

            int level = 0;
            dfs_euler(root, level);
            build_rmq();
            bfs(root);
        }

        int get_lca(int x, int y){
            int start_idx = min(first_pos[x], first_pos[y]);
            int end_idx = max(first_pos[x], first_pos[y]);
            int range_len = end_idx - start_idx + 1;

            int lca_x_y = -1;
            int j = my_log2[range_len];
            int l_idx = rmq[start_idx][j];
            int r_idx = rmq[end_idx - (1 << j) + 1][j];

            if(node_level[l_idx].second < node_level[r_idx].second){
                lca_x_y = node_level[l_idx].first;
            }else{
                lca_x_y = node_level[r_idx].first;
            }

            return lca_x_y;
        }

        int get_dist(int x, int y){
            int lca_x_y = get_lca(x, y);
            return d[x] + d[y] - 2 * d[lca_x_y];
        }
};

bool is_ok(const int& dist, const int& k){
    return (dist <= k) && ((k - dist) % 2 == 0);
}

int main(int argc, char** argv){
    #ifndef ONLINE_JUDGE
        freopen((string(argv[1]) + ".in").c_str(), "r", stdin);
        freopen((string(argv[1]) + ".out").c_str(), "w", stdout);
    #endif

    int n;
    scanf("%d\n", &n);

    vector<vector<int>> a(n + 1, vector<int>());
    int x, y;
    for(int i = 1; i <= n - 1; ++i){
        scanf("%d %d\n", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }

    Tree tree(a, n);

    int q, src, dest, k;
    scanf("%d\n", &q);

    for(; q > 0; --q){
        scanf("%d %d %d %d %d\n", &x, &y, &src, &dest, &k);

        int dist_src_dest = tree.get_dist(src, dest);
        int dist_src_x = tree.get_dist(src, x);
        int dist_src_y = tree.get_dist(src, y);
        int dist_dest_x = tree.get_dist(dest, x);
        int dist_dest_y = tree.get_dist(dest, y);
        int dist_x_y = 1; // because we add edge (x, y)

        int d1 = dist_src_dest;
        int d2 = dist_src_x + dist_x_y + dist_dest_y;
        int d3 = dist_src_y + dist_x_y + dist_dest_x;

        bool is_ok_1 = is_ok(d1, k);
        bool is_ok_2 = is_ok(d2, k);
        bool is_ok_3 = is_ok(d3, k);

        string ans = (is_ok_1 || is_ok_2 || is_ok_3 ? "YES" : "NO");

        printf("%s\n", ans.c_str());
    }

    return 0;
}


#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

class Tree{
public:
    vector<vector<int>> a;
    vector<int> first_pos;
    vector<pair<int, int>> node_level;
    vector<vector<int>> rmq;
    vector<int> my_log2;
    vector<int> d;
    int root;
    int n;

    void euler_dfs(int x, int level){
        node_level.push_back({x, level});
        if(first_pos[x] == -1){
            first_pos[x] = node_level.size();
        }

        for(int y: a[x]){
            if(first_pos[y] == -1){
                euler_dfs(y, level + 1);
                node_level.push_back({x, level});
            }
        }
    }

    void build_rmq(){
        int p = 1;
        int cur_log = 1;

        my_log2.resize(node_level.size() + 1, 0);
        for(int i = 2; i <= node_level.size(); ++i){
            my_log2[i] = 1 + my_log2[i / 2];
        }

        rmq.resize(node_level.size() + 1, vector<int>(my_log2[node_level.size()] + 1, n + 1));
        for(int i = 1; i <= rmq.size() - 1; ++i){
            rmq[i][0] = i - 1;
        }
        /*
        int j = 0;
        printf("rmq[][%d] = \n", j);
        for(int i = 1; i <= rmq.size() - 1; ++i){
                printf("%d ", rmq[i][j]);
        }
        printf("\n");
        */
        for(int j = 1; j <= rmq[0].size() - 1; ++j){
            int range_len = (1 << j);
            for(int i = 1; i <= rmq.size() - range_len; ++i){
                int l_idx = rmq[i][j - 1];
                int r_idx = rmq[i + range_len / 2][j - 1];
                if(node_level[l_idx].second < node_level[r_idx].second){
                    rmq[i][j] = l_idx;
                }else{
                    rmq[i][j] = r_idx;
                }
            }
            /*
            printf("rmq[][%d] = \n", j);
            for(int i = 1; i <= rmq.size() - 1; ++i){
                    printf("%d ", rmq[i][j]);
            }
            printf("\n");
            */
        }

        //printf("rmq.size() = %d\n", rmq.size());
        //printf("rmq[0].size() = %d\n", rmq[0].size());
    }

    void bfs(const int& src){
        fill(d.begin(), d.end(), -1);
        d[src] = 0;

        queue<int> q;
        q.push(src);

        while(!q.empty()){
            int x = q.front();
            q.pop();

            for(int y: a[x]){
                if(d[y] == -1){
                    d[y] = 1 + d[x];
                    q.push(y);
                }
            }
        }
    }

    void print_node_level(){
        printf("\nnode_level\n");
        for(auto p: node_level){
            printf("%d ", p.first);
        }
        printf("\n");
        for(auto p: node_level){
            printf("%d ", p.second);
        }
        printf("\n");
    }

public:
    Tree(vector<vector<int>> a, int n){
        this->a = a;
        this->n = n;
        this->first_pos.resize(n + 1, -1);
        this->root = 1;
        this->d.resize(n + 1);

        int level = 0;
        euler_dfs(root, level);
        build_rmq();
        bfs(root);
    }

    int get_lca(int x, int y){
        if(x == y){
            return y;
        }

        int start_idx = min(first_pos[x], first_pos[y]);
        int end_idx = max(first_pos[x], first_pos[y]);
        int range_len = end_idx - start_idx + 1;

        int lca_x_y = -1;

        int j = my_log2[range_len];

        //printf("x = %d, y = %d\n", x, y);
        //printf("start_idx = %d, end_idx = %d, range_len = %d, j = %d\n",
        //    start_idx, end_idx, range_len, j);

        int l_idx = rmq[start_idx][j];
        //printf("l_idx = %d\n", l_idx);

        int r_idx = rmq[end_idx - (1 << j) + 1][j];
        //printf("r_idx = %d\n", r_idx);

        if(node_level[l_idx].second < node_level[r_idx].second){
            lca_x_y = node_level[l_idx].first;
        }else{
            lca_x_y = node_level[r_idx].first;
        }

        return lca_x_y;
    }

    int get_dist(int x, int y){
        if(x == y){
            return 0;
        }
        int lca_x_y = get_lca(x, y);
        return d[x] + d[y] - 2 * d[lca_x_y];
    }
};

bool is_ok(const int& dist, const int& k){
    return (dist <= k) && ((k - dist) % 2 == 0);
}

int main(int argc, char** argv){
    #ifndef ONLINE_JUDGE
        freopen((string(argv[1]) + ".in").c_str(), "r", stdin);
        freopen((string(argv[1]) + ".out").c_str(), "w", stdout);
    #endif

    int n;
    scanf("%d\n", &n);

    vector<vector<int>> a(n + 1, vector<int>());
    int x, y;
    for(int i = 1; i <= n - 1; ++i){
        scanf("%d %d\n", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }

    Tree tree(a, n);

    //tree.print_node_level();
    //tree.build_rmq();
    /*
    for(int x = 1; x <= n; ++x){
        for(int y = x; y <= n; ++y){
            printf("lca(%d, %d) = %d\n", x, y, tree.get_lca(x, y));
        }
    }

    for(int x = 1; x <= n; ++x){
        for(int y = x; y <= n; ++y){
            printf("dist(%d, %d) = %d\n", x, y, tree.get_dist(x, y));
        }
    }
    */
    int q, src, dest, k;
    scanf("%d\n", &q);

    for(; q > 0; --q){
        scanf("%d %d %d %d %d\n", &x, &y, &src, &dest, &k);

        int dist_src_dest = tree.get_dist(src, dest);
        int dist_src_x = tree.get_dist(src, x);
        int dist_src_y = tree.get_dist(src, y);
        int dist_dest_x = tree.get_dist(dest, x);
        int dist_dest_y = tree.get_dist(dest, y);
        int dist_x_y = 1; // because we add edge (x, y)

        int d1 = dist_src_dest;
        int d2 = dist_src_x + dist_x_y + dist_dest_y;
        int d3 = dist_src_y + dist_x_y + dist_dest_x;

        bool is_ok_1 = is_ok(d1, k);
        bool is_ok_2 = is_ok(d2, k);
        bool is_ok_3 = is_ok(d3, k);

        /*
        printf("is_ok_1: %d, (d1 = %d, k = %d)\n", is_ok_1, d1, k);
        printf("is_ok_2: %d, (d2 = %d, k = %d)\n", is_ok_2, d2, k);
        printf("is_ok_3: %d, (d3 = %d, k = %d)\n", is_ok_3, d3, k);
        */

        string ans = (is_ok_1 || is_ok_2 || is_ok_3 ? "YES" : "NO");

        printf("%s\n", ans.c_str());
    }

    return 0;
}


#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

void bfs(vector<vector<int>>& a, const int& n, const int& src, vector<int>& d){
    fill(d.begin(), d.end(), -1);
    d[src] = 0;

    queue<int> q;
    q.push(src);

    while(!q.empty()){
        int x = q.front();
        q.pop();

        for(int y: a[x]){
            if(d[y] == -1){
                d[y] = 1 + d[x];
                q.push(y);
            }
        }
    }
}

bool is_ok(const int& min_dist, const int& dist, const int& k){
    if(k < min_dist){
        return 0;
    }
    return ((dist - k) % 2 == 0);
}

int main(int argc, char** argv){
    #ifndef ONLINE_JUDGE
        freopen((string(argv[1]) + ".in").c_str(), "r", stdin);
        freopen((string(argv[1]) + ".out").c_str(), "w", stdout);
    #endif

    int n;
    scanf("%d\n", &n);

    vector<vector<int>> a(n + 1, vector<int>());
    int x, y;
    for(int i = 1; i <= n - 1; ++i){
        scanf("%d %d\n", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }

    vector<int> d(n + 1);
    bfs(a, n, 1, d);

    int q, src, dest, k;
    scanf("%d\n", &q);

    for(; q > 0; --q){
        scanf("%d %d %d %d %d\n", &x, &y, &src, &dest, &k);

        int dist_src_dest = abs(d[src] - d[dest]);
        int dist_src_x = abs(d[src] - d[x]);
        int dist_src_y = abs(d[src] - d[y]);
        int dist_dest_x = abs(d[dest] - d[x]);
        int dist_dest_y = abs(d[dest] - d[y]);
        int dist_x_y = 1; // not abs(d[x] - d[y]), because we add edge (x, y)

        int d1 = dist_src_dest;
        int d2 = dist_src_x + dist_x_y + dist_dest_y;
        int d3 = dist_src_y + dist_x_y + dist_dest_x;
        int min_dist = min(d1, min(d2, d3));

        bool is_ok_1 = is_ok(min_dist, d1, k);
        bool is_ok_2 = is_ok(min_dist, d2, k);
        bool is_ok_3 = is_ok(min_dist, d3, k);

        string ans = (is_ok_1 || is_ok_2 || is_ok_3 ? "YES" : "NO");

        printf("%s\n", ans.c_str());
    }

    return 0;
}


#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

void bfs(vector<vector<int>>& a, const int& n, const int& src, vector<int>& d){
    fill(d.begin(), d.end(), -1);
    d[src] = 0;

    queue<int> q;
    q.push(src);

    while(!q.empty()){
        int x = q.front();
        q.pop();

        for(int y: a[x]){
            if(d[y] == -1){
                d[y] = 1 + d[x];
                q.push(y);
            }
        }
    }
}

bool is_ok(const int& dist, const int& k){
    return (dist <= k) && ((k - dist) % 2 == 0);
}

int main(int argc, char** argv){
    #ifndef ONLINE_JUDGE
        freopen((string(argv[1]) + ".in").c_str(), "r", stdin);
        freopen((string(argv[1]) + ".out").c_str(), "w", stdout);
    #endif

    int n;
    scanf("%d\n", &n);

    vector<vector<int>> a(n + 1, vector<int>());
    int x, y;
    for(int i = 1; i <= n - 1; ++i){
        scanf("%d %d\n", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }

    vector<int> d(n + 1);
    bfs(a, n, 1, d);

    int q, src, dest, k;
    scanf("%d\n", &q);

    for(; q > 0; --q){
        scanf("%d %d %d %d %d\n", &x, &y, &src, &dest, &k);

        int dist_src_dest = abs(d[src] - d[dest]);
        int dist_src_x = abs(d[src] - d[x]);
        int dist_src_y = abs(d[src] - d[y]);
        int dist_dest_x = abs(d[dest] - d[x]);
        int dist_dest_y = abs(d[dest] - d[y]);
        int dist_x_y = 1; // not abs(d[x] - d[y]), because we add edge (x, y)

        int d1 = dist_src_dest;
        int d2 = dist_src_x + dist_x_y + dist_dest_y;
        int d3 = dist_src_y + dist_x_y + dist_dest_x;

        bool is_ok_1 = is_ok(d1, k);
        bool is_ok_2 = is_ok(d2, k);
        bool is_ok_3 = is_ok(d3, k);

        /*
        printf("is_ok_1: %d, (d1 = %d, k = %d)\n", is_ok_1, d1, k);
        printf("is_ok_2: %d, (d2 = %d, k = %d)\n", is_ok_2, d2, k);
        printf("is_ok_3: %d, (d3 = %d, k = %d)\n", is_ok_3, d3, k);
        */

        string ans = (is_ok_1 || is_ok_2 || is_ok_3 ? "YES" : "NO");

        printf("%s\n", ans.c_str());
    }

    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

const ll N = 1e5 + 100;

ll n, m;
ll col[N], mark[N], ok[N];
vector <ll> g[N], p;

ll DFS (ll v){
    mark[v] = 1;
    ok[v] = 1;
    p.push_back(v);
    for (ll u : g[v]){
        if (!mark[u]){
            ll c = DFS(u);
            p.push_back(v);
            if (c != col[u]){
                p.push_back(u);
                p.push_back(v);
                ok[u] ^= 1;
                ok[v] ^= 1;
            }
            ok[v] ^= 1;
        }
    }
    return ok[v];
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll u, v, source;
    cin >> n >> m;
    for (ll i = 1; i <= m; i ++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (ll i = 1; i <= n; i ++){
        cin >> col[i];
        if (col[i] == 1)
            source = i;
    }
    DFS(source);
    ll e = p.size();
    if (ok[source] != col[source])
        e = p.size() - 1;
    ll t1 = 0, t2 = 0;
    for (ll i = 1; i <= n; i ++){
        if (mark[i] == 1 && col[i] == 1)
            t1 = 1;
        if (mark[i] == 0 && col[i] == 1)
            t2 = 1;
    }
    if (t1 + t2 == 2)
        return cout << -1, 0;
    cout << e << '\n';
    for (ll i = 0; i < e; i ++)
        cout << p[i] << " ";
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

const ll N = 1e5 + 100;

ll n, m;
ll col[N], mark[N], ok[N];
vector <ll> g[N], p;

ll DFS (ll v){
    mark[v] = 1;
    ok[v] = 1;
    p.push_back(v);
    for (ll u : g[v]){
        if (!mark[u]){
            ll c = DFS(u);
            p.push_back(v);
            if (c != col[u]){
                p.push_back(u);
                p.push_back(v);
                ok[u] ^= 1;
                ok[v] ^= 1;
            }
            ok[v] ^= 1;
        }
    }
    return ok[v];
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll u, v, source = -1;
    cin >> n >> m;
    for (ll i = 1; i <= m; i ++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (ll i = 1; i <= n; i ++){
        cin >> col[i];
        if (col[i] == 1)
            source = i;
    }
    if (source == -1)
        return cout << 0, 0;
    DFS(source);
    ll e = p.size();
    if (ok[source] != col[source])
        e = p.size() - 1;
    ll t1 = 0, t2 = 0;
    for (ll i = 1; i <= n; i ++){
        if (mark[i] == 1 && col[i] == 1)
            t1 = 1;
        if (mark[i] == 0 && col[i] == 1)
            t2 = 1;
    }
    if (t1 + t2 == 2)
        return cout << -1, 0;
    cout << e << '\n';
    for (ll i = 0; i < e; i ++)
        cout << p[i] << " ";
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

const ll N = 1e5 + 100;

ll n, m;
ll col[N], mark[N], ok[N];
vector <ll> g[N], p;

ll DFS (ll v){
    mark[v] = 1;
    ok[v] = 1;
    p.push_back(v);
    for (ll u : g[v]){
        if (!mark[u]){
            ll c = DFS(u);
            p.push_back(v);
            if (c != col[u]){
                p.push_back(u);
                p.push_back(v);
                ok[u] ^= 1;
                ok[v] ^= 1;
            }
            ok[v] ^= 1;
        }
    }
    return ok[v];
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll u, v, source = -1;
    cin >> n >> m;
    for (ll i = 1; i <= m; i ++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (ll i = 1; i <= n; i ++){
        cin >> col[i];
        if (col[i] == 1)
            source = i;
    }
    if (source == -1)
        return cout << 0;
    DFS(source);
    ll e = p.size();
    if (ok[source] != col[source])
        e = p.size() - 1;
    ll t1 = 0, t2 = 0;
    for (ll i = 1; i <= n; i ++){
        if (mark[i] == 1 && col[i] == 1)
            t1 = 1;
        if (mark[i] == 0 && col[i] == 1)
            t2 = 1;
    }
    if (t1 + t2 == 2)
        return cout << -1, 0;
    cout << e << '\n';
    for (ll i = 0; i < e; i ++)
        cout << p[i] << " ";
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

const ll N = 1e5 + 100;

ll n, m;
ll col[N], mark[N], ok[N];
vector <ll> g[N], p;

ll DFS (ll v){
    mark[v] = 1;
    ok[v] = 1;
    p.push_back(v);
    for (ll u : g[v]){
        if (!mark[u]){
            ll c = DFS(u);
            p.push_back(v);
            if (c != col[u]){
                p.push_back(u);
                p.push_back(v);
                ok[u] ^= 1;
                ok[v] ^= 1;
            }
            ok[v] ^= 1;
        }
    }
    return ok[v];
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll u, v;
    cin >> n >> m;
    for (ll i = 1; i <= m; i ++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (ll i = 1; i <= n; i ++)
        cin >> col[i];
    DFS(1);
    ll e = p.size();
    if (ok[1] != col[1])
        e = p.size() - 1;
    for (ll i = 1; i <= n; i ++){
        if (mark[i] == 0)
            return cout << -1, 0;
    }
    cout << e << '\n';
    for (ll i = 0; i < e; i ++)
        cout << p[i] << " ";
    return 0;
}


#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const int L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#ifndef dd
#define dd c = gc()
#endif
template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

const int maxn = 100005;

int fa[maxn];
int xx[maxn];

int n, m;

inline int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

struct Edge {
	int to, nxt;
} e[maxn << 1];

int first[maxn];

inline void add_edge(int from, int to) {
	static int cnt = 0;
	e[++cnt].nxt = first[from];
	first[from] = cnt;
	e[cnt].to = to;
	e[++cnt].nxt = first[to];
	first[to] = cnt;
	e[cnt].to = from;
}

vector<int> ve;

bool vis[maxn];

inline void dfs(int now, int fa) {
//	cout << now << endl;
	vis[now] = true;
	ve.push_back(now);
	xx[now] ^= 1;
	for (int i = first[now]; i; i = e[i].nxt) {
		int to = e[i].to;
		if (to != fa) {
			dfs(to, now);
			ve.push_back(now);
			xx[now] ^= 1;
			if (xx[to]) {
				ve.push_back(to);
				ve.push_back(now);
				xx[to] ^= 1;
				xx[now] ^= 1;
			}
		}
	}
}

vector<int> ans;

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i;
	}
	for (int i = 1, f, t; i <= m; ++i) {
		read(f), read(t);
		int fax = getfa(f);
		int fay = getfa(t);
		if (fax != fay) {
			add_edge(f, t);
//			cout << "add_edge " << f << ' ' << t << endl;
			fa[fax] = fay;
		}
	}
	for (int i = 1; i <= n; ++i) {
		read(xx[i]);
	}
	bool flg = false;
	for (int rt = 1; rt <= n; ++rt) {
		if (!vis[rt]) {
			ve.clear();
			dfs(rt, 0);
			if (xx[rt]) {
				ve.erase(ve.begin());
				xx[rt] = 0;
			}
			if (ve.size()) {
				if (flg) {
					puts("-1");
					return 0;
				} else {
					flg = true;
				}
			}
			for (auto x : ve) {
				ans.push_back(x);
			}
		}
	}
	printf("%u\n", ans.size());
	for (auto x : ans) {
		printf("%d ", x);
	}
	return 0;
}


#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const int L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#ifndef dd
#define dd c = gc()
#endif
template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

const int maxn = 100005;

int fa[maxn];
int xx[maxn];

int n, m;

inline int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

struct Edge {
	int to, nxt;
} e[maxn << 1];

int first[maxn];

inline void add_edge(int from, int to) {
	static int cnt = 0;
	e[++cnt].nxt = first[from];
	first[from] = cnt;
	e[cnt].to = to;
	e[++cnt].nxt = first[to];
	first[to] = cnt;
	e[cnt].to = from;
}

vector<int> ve;

bool vis[maxn];

inline void dfs(int now, int fa) {
//	cout << now << endl;
	vis[now] = true;
	ve.push_back(now);
	xx[now] ^= 1;
	for (int i = first[now]; i; i = e[i].nxt) {
		int to = e[i].to;
		if (to != fa) {
			dfs(to, now);
			ve.push_back(now);
			xx[now] ^= 1;
			if (xx[to]) {
				ve.push_back(to);
				ve.push_back(now);
				xx[to] ^= 1;
				xx[now] ^= 1;
			}
		}
	}
}

vector<int> ans;

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i;
	}
	for (int i = 1, f, t; i <= m; ++i) {
		read(f), read(t);
		int fax = getfa(f);
		int fay = getfa(t);
		if (fax != fay) {
			add_edge(f, t);
//			cout << "add_edge " << f << ' ' << t << endl;
			fa[fax] = fay;
		}
	}
	for (int i = 1; i <= n; ++i) {
		read(xx[i]);
	}
	for (int rt = 1; rt <= n; ++rt) {
		if (!vis[rt]) {
			ve.clear();
			dfs(rt, 0);
			if (xx[rt]) {
				ve.erase(ve.begin());
			}
			for (auto x : ve) {
				ans.push_back(x);
			}
		}
	}
	printf("%u\n", ans.size());
	for (auto x : ans) {
		printf("%d ", x);
	}
	return 0;
}


#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const int L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#ifndef dd
#define dd c = gc()
#endif
template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

const int maxn = 100005;

int fa[maxn];
int xx[maxn];

int n, m;

inline int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

struct Edge {
	int to, nxt;
} e[maxn << 1];

int first[maxn];

inline void add_edge(int from, int to) {
	static int cnt = 0;
	e[++cnt].nxt = first[from];
	first[from] = cnt;
	e[cnt].to = to;
	e[++cnt].nxt = first[to];
	first[to] = cnt;
	e[cnt].to = from;
}

vector<int> ve;

bool vis[maxn];

inline void dfs(int now, int fa) {
//	cout << now << endl;
	vis[now] = true;
	ve.push_back(now);
	xx[now] ^= 1;
	for (int i = first[now]; i; i = e[i].nxt) {
		int to = e[i].to;
		if (to != fa) {
			dfs(to, now);
			ve.push_back(now);
			xx[now] ^= 1;
			if (xx[to]) {
				ve.push_back(to);
				ve.push_back(now);
				xx[to] ^= 1;
				xx[now] ^= 1;
			}
		}
	}
}

inline bool pan(int now, int fa) {
	if (xx[now]) {
		return true;
	}
	for (int i = first[now]; i; i = e[i].nxt) {
		if (e[i].to != fa && pan(e[i].to, now)) {
			return true;
		}
	}
	return false;
}

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i;
	}
	for (int i = 1, f, t; i <= m; ++i) {
		read(f), read(t);
		int fax = getfa(f);
		int fay = getfa(t);
		if (fax != fay) {
			add_edge(f, t);
//			cout << "add_edge " << f << ' ' << t << endl;
			fa[fax] = fay;
		}
	}
	for (int i = 1; i <= n; ++i) {
		read(xx[i]);
	}
	bool flg = false;
	for (int rt = 1; rt <= n; ++rt) {
		if (!vis[rt]) {
			if (pan(rt, 0)) {
				if (!flg) {
					flg = true;
					ve.clear();
					dfs(rt, 0);
					if (xx[rt]) {
						ve.erase(ve.begin());
						xx[rt] = 0;
					}
				} else {
					puts("-1");
					return 0;
				}
			}
		}
	}
	printf("%u\n", ve.size());
	for (auto x : ve) {
		printf("%d ", x);
	}
	return 0;
}


#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const int L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#ifndef dd
#define dd c = gc()
#endif
template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

const int maxn = 100005;

int fa[maxn];
int xx[maxn];

int n, m;

inline int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

struct Edge {
	int to, nxt;
} e[maxn << 1];

int first[maxn];

inline void add_edge(int from, int to) {
	static int cnt = 0;
	e[++cnt].nxt = first[from];
	first[from] = cnt;
	e[cnt].to = to;
	e[++cnt].nxt = first[to];
	first[to] = cnt;
	e[cnt].to = from;
}

vector<int> ve;

inline void dfs(int now, int fa) {
//	cout << now << endl;
	ve.push_back(now);
	xx[now] ^= 1;
	for (int i = first[now]; i; i = e[i].nxt) {
		int to = e[i].to;
		if (to != fa) {
			dfs(to, now);
			ve.push_back(now);
			xx[now] ^= 1;
			if (xx[to]) {
				ve.push_back(to);
				ve.push_back(now);
				xx[to] ^= 1;
				xx[now] ^= 1;
			}
		}
	}
}

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i;
	}
	for (int i = 1, f, t; i <= m; ++i) {
		read(f), read(t);
		int fax = getfa(f);
		int fay = getfa(t);
		if (fax != fay) {
			add_edge(f, t);
//			cout << "add_edge " << f << ' ' << t << endl;
			fa[fax] = fay;
		}
	}
	for (int i = 1; i <= n; ++i) {
		read(xx[i]);
	}
	dfs(1, 0);
	if (xx[1]) {
		ve.erase(ve.begin());
	}
	printf("%u\n", ve.size());
	for (auto x : ve) {
		printf("%d ", x);
	}
	return 0;
}


#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const int L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#ifndef dd
#define dd c = gc()
#endif
template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

const int maxn = 100005;

int fa[maxn];
int xx[maxn];

int n, m;

inline int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

struct Edge {
	int to, nxt;
} e[maxn << 1];

int first[maxn];

inline void add_edge(int from, int to) {
	static int cnt = 0;
	e[++cnt].nxt = first[from];
	first[from] = cnt;
	e[cnt].to = to;
	e[++cnt].nxt = first[to];
	first[to] = cnt;
	e[cnt].to = from;
}

vector<int> ve;

inline void dfs(int now, int fa) {
//	cout << now << endl;
	ve.push_back(now);
	xx[now] ^= 1;
	for (int i = first[now]; i; i = e[i].nxt) {
		int to = e[i].to;
		if (to != fa) {
			dfs(to, now);
			ve.push_back(now);
			xx[now] ^= 1;
			if (xx[to]) {
				ve.push_back(to);
				ve.push_back(now);
				xx[to] ^= 1;
				xx[now] ^= 1;
			}
		}
	}
}

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i;
	}
	for (int i = 1, f, t; i <= m; ++i) {
		read(f), read(t);
		int fax = getfa(f);
		int fay = getfa(t);
		if (fax != fay) {
			add_edge(f, t);
//			cout << "add_edge " << f << ' ' << t << endl;
			fa[fax] = fay;
		}
	}
	for (int i = 1; i <= n; ++i) {
		read(xx[i]);
	}
	dfs(1, 0);
	if (xx[1]) {
		ve.erase(ve.begin());
	}
	printf("%llu\n", ve.size());
	for (auto x : ve) {
		printf("%d ", x);
	}
	return 0;
}


#include <iostream>
#include <limits>
#include <climits>
#include <deque>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;

class solver {
private:
    vector<vector<int>> neig;

    void build(map<int, set<int>> &sub_neig, unordered_set<int> &used, int v) {
        used.insert(v);
        sub_neig[v] = set<int>();
        for (auto it : neig[v]) {
            if (!used.count(it)) {
                sub_neig[v].insert(it);
                build(sub_neig, used, it);
            }
        }
    }

    void go(map<int, set<int>> &sub_neig, vector<int> &story, vector<int> &needs, int v, int prev) {
        sub_neig[v] = set<int>();

        story.push_back(v);
        needs[v] ^= 1;

        for (auto it : sub_neig[v]) {
            go(sub_neig, story, needs, it, v);

            story.push_back(v);
            needs[v] ^= 1;
        }

        if (needs[v] == 1) {
            if (prev != -1) {
                story.push_back(prev);
                needs[prev] ^= 1;

                story.push_back(v);
                needs[v] ^= 1;
            } else {
                story.pop_back();
            }
        }
    }

public:
    void solve(int n, int m) {
        neig.resize(n);
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            neig[a].push_back(b);
            neig[b].push_back(a);
        }

        vector<int> need(n);
        for (auto &it : need) {
            cin >> it;
        }

        unordered_set<int> used;
        map<int, set<int>> target;
        int need_comps = 0;
        for (int i = 0; i < n; i++) {
            if (used.count(i)) {
                continue;
            }
            map<int, set<int>> sub;
            build(sub, used, i);

            bool need_dfs = false;
            for (auto &pr : sub) {
                if (need[pr.first]) {
                    need_dfs = true;
                }
                for (auto it : pr.second) {
                    if (need[it]) {
                        need_dfs = true;
                    }
                }
            }

            if (need_dfs) {
                need_comps++;
                if (need_comps > 1) {
                    cout << -1 << endl;
                    return;
                }
                target = sub;
            }
        }

        vector<int> res;
        go(target, res, need, (*target.begin()).first, -1);

        cout << res.size() << endl;
        for (auto it : res) {
            cout << it + 1 << " ";
        }
        cout << endl;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    while (cin >> n >> m) {
        solver s;
        s.solve(n, m);
    }
}


#include <iostream>
#include <limits>
#include <climits>
#include <deque>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;

class solver {
private:
    vector<vector<int>> neig;

    void build(map<int, set<int>> &sub_neig, unordered_set<int> &used, int v) {
        used.insert(v);
        for (auto it : neig[v]) {
            if (!used.count(it)) {
                sub_neig[v].insert(it);
                build(sub_neig, used, it);
            }
        }
    }

    void go(map<int, set<int>> &sub_neig, vector<int> &story, vector<int> &needs, int v, int prev) {
        story.push_back(v);
        needs[v] ^= 1;

        for (auto it : sub_neig[v]) {
            go(sub_neig, story, needs, it, v);

            story.push_back(v);
            needs[v] ^= 1;
        }

        if (needs[v] == 1) {
            if (prev != -1) {
                story.push_back(prev);
                needs[prev] ^= 1;

                story.push_back(v);
                needs[v] ^= 1;
            } else {
                story.pop_back();
            }
        }
    }

public:
    void solve(int n, int m) {
        neig.resize(n);
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            neig[a].push_back(b);
            neig[b].push_back(a);
        }

        vector<int> need(n);
        for (auto &it : need) {
            cin >> it;
        }

        unordered_set<int> used;
        map<int, set<int>> target;
        int need_comps = 0;
        for (int i = 0; i < n; i++) {
            if (used.count(i)) {
                continue;
            }
            map<int, set<int>> sub;
            build(sub, used, i);

            bool need_dfs = false;
            for (auto &pr : sub) {
                if (need[pr.first]) {
                    need_dfs = true;
                }
            }

            if (need_dfs) {
                need_comps++;
                if (need_comps > 1) {
                    cout << -1 << endl;
                    return;
                }
                target = sub;
            }
        }

        vector<int> res;
        go(target, res, need, (*target.begin()).first, -1);

        cout << res.size() << endl;
        for (auto it : res) {
            cout << it + 1 << " ";
        }
        cout << endl;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    while (cin >> n >> m) {
        solver s;
        s.solve(n, m);
    }
}


#include <iostream>
#include <limits>
#include <climits>
#include <deque>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;

class solver {
private:
    vector<vector<int>> neig;

    void build(map<int, set<int>> &sub_neig, unordered_set<int> &used, int v) {
        used.insert(v);
        for (auto it : neig[v]) {
            if (!used.count(it)) {
                sub_neig[v].insert(it);
                build(sub_neig, used, it);
            }
        }
    }

    void go(map<int, set<int>> &sub_neig, vector<int> &story, vector<int> &needs, int v, int prev) {
        story.push_back(v);
        needs[v] ^= 1;

        for (auto it : sub_neig[v]) {
            go(sub_neig, story, needs, it, v);

            story.push_back(v);
            needs[v] ^= 1;
        }

        if (needs[v] == 1) {
            if (prev != -1) {
                story.push_back(prev);
                needs[prev] ^= 1;

                story.push_back(v);
                needs[v] ^= 1;
            } else {
                story.pop_back();
            }
        }
    }

public:
    void solve(int n, int m) {
        neig.resize(n);
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            neig[a].push_back(b);
            neig[b].push_back(a);
        }

        vector<int> need(n);
        for (auto &it : need) {
            cin >> it;
        }

        unordered_set<int> used;
        map<int, set<int>> target;
        int need_comps = 0;
        for (int i = 0; i < n; i++) {
            if (used.count(i)) {
                continue;
            }
            map<int, set<int>> sub;
            build(sub, used, i);

            bool need_dfs = false;
            for (auto &pr : sub) {
                if (need[pr.first]) {
                    need_dfs = true;
                }
                for (auto it : pr.second) {
                    if (need[it]) {
                        need_dfs = true;
                    }
                }
            }

            if (need_dfs) {
                need_comps++;
                if (need_comps > 1) {
                    cout << -1 << endl;
                    return;
                }
                target = sub;
            }
        }

        vector<int> res;
        go(target, res, need, (*target.begin()).first, -1);

        cout << res.size() << endl;
        for (auto it : res) {
            cout << it + 1 << " ";
        }
        cout << endl;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    while (cin >> n >> m) {
        solver s;
        s.solve(n, m);
    }
}


#include <iostream>
#include <limits>
#include <climits>
#include <deque>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;

class solver {
private:
    vector<vector<int>> neig;

    void build(map<int, set<int>> &sub_neig, unordered_set<int> &used, int v) {
        used.insert(v);
        sub_neig[v] = set<int>();
        for (auto it : neig[v]) {
            if (!used.count(it)) {
                sub_neig[v].insert(it);
                build(sub_neig, used, it);
            }
        }
    }

    void go(map<int, set<int>> &sub_neig, vector<int> &story, vector<int> &needs, int v, int prev) {
        story.push_back(v);
        needs[v] ^= 1;

        for (auto it : sub_neig[v]) {
            go(sub_neig, story, needs, it, v);

            story.push_back(v);
            needs[v] ^= 1;
        }

        if (needs[v] == 1) {
            if (prev != -1) {
                story.push_back(prev);
                needs[prev] ^= 1;

                story.push_back(v);
                needs[v] ^= 1;
            } else {
                story.pop_back();
            }
        }
    }

public:
    void solve(int n, int m) {
        neig.resize(n);
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            neig[a].push_back(b);
            neig[b].push_back(a);
        }

        vector<int> need(n);
        for (auto &it : need) {
            cin >> it;
        }

        unordered_set<int> used;
        map<int, set<int>> target;
        int need_comps = 0;
        for (int i = 0; i < n; i++) {
            if (used.count(i)) {
                continue;
            }
            map<int, set<int>> sub;
            build(sub, used, i);

            bool need_dfs = false;
            for (auto &pr : sub) {
                if (need[pr.first]) {
                    need_dfs = true;
                }
                for (auto it : pr.second) {
                    if (need[it]) {
                        need_dfs = true;
                    }
                }
            }

            if (need_dfs) {
                need_comps++;
                if (need_comps > 1) {
                    cout << -1 << endl;
                    return;
                }
                target = sub;
            }
        }

        vector<int> res;
        go(target, res, need, (*target.begin()).first, -1);

        cout << res.size() << endl;
        for (auto it : res) {
            cout << it + 1 << " ";
        }
        cout << endl;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    while (cin >> n >> m) {
        solver s;
        s.solve(n, m);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,m,op,tot,w[N],f[N],fs[N],fa[N],que[N];
struct edge{int u,v,t;}edg[N];
inline int read(){
    int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
    while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
inline int find(int u){
	if(f[u]==u) return f[u]; return f[u]=find(f[u]);
}
inline void addedge(int u,int v){
	tot++,edg[tot].u=u,edg[tot].v=v,edg[tot].t=fs[u],fs[u]=tot;
}
inline void dfsit(int u){
	que[++que[0]]=u; bool fl=false;
	for(int i=fs[u];i>0;i=edg[i].t){
		int x=edg[i].v; if(fa[u]==x) continue; fa[x]=u,dfsit(x); fl=true;
	}
	if(!fl) w[u]^=1;
	if(w[u]&&u!=op) w[u]^=1,w[fa[u]]^=1,que[++que[0]]=fa[u],que[++que[0]]=u; if(fa[u]) que[++que[0]]=fa[u];
}
int main(){
	n=read(),m=read(); int u,v;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=m;i++){
		u=read(),v=read(); f[u]=find(u),f[v]=find(v); if(f[u]==f[v]) continue;
		addedge(u,v),addedge(v,u),f[f[u]]=f[v];
	}
	for(int i=1;i<=n;i++) w[i]=read();
	for(int i=1;i<=n;i++){
		if(w[i]){
			if(!op) op=find(i);
			if(find(i)!=op){
				puts("-1"); return 0;}
		}
	}
	if(!op){puts("0"); return 0;}
	dfsit(op);
	if(!w[op]){
		printf("%d\n",que[0]); for(int i=1;i<=que[0];i++) printf("%d ",que[i]);
	}
	else{
		printf("%d\n",que[0]-1); for(int i=2;i<=que[0];i++) printf("%d ",que[i]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,m,op,tot,w[N],f[N],fs[N],fa[N],que[N];
struct edge{int u,v,t;}edg[N];
inline int read(){
    int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
    while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
inline int find(int u){
	if(f[u]==u) return f[u]; return f[u]=find(f[u]);
}
inline void addedge(int u,int v){
	tot++,edg[tot].u=u,edg[tot].v=v,edg[tot].t=fs[u],fs[u]=tot;
}
inline void dfsit(int u){
	que[++que[0]]=u; bool fl=false;
	for(int i=fs[u];i>0;i=edg[i].t){
		int x=edg[i].v; if(fa[u]==x) continue; fa[x]=u,dfsit(x); fl=true;
	}
	if(!fl) w[u]^=1;
	if(w[u]&&u!=op) w[u]^=1,w[fa[u]]^=1,que[++que[0]]=fa[u],que[++que[0]]=u; if(fa[u]) que[++que[0]]=fa[u];
}
int main(){
	n=read(),m=read(); int u,v;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=m;i++){
		u=read(),v=read(); f[u]=find(u),f[v]=find(v); if(f[u]==f[v]) continue;
		addedge(u,v),addedge(v,u),f[f[u]]=f[v];
	}
	for(int i=1;i<=n;i++) w[i]=read();
	for(int i=1;i<=n;i++){
		if(w[i]){
			if(!op) op=find(i);
			if(find(i)!=op){
				puts("-1"); return 0;}
		}
	}
	cout<<op<<endl;
	if(!op){puts("0"); return 0;}
	dfsit(op);
	if(!w[op]){
		printf("%d\n",que[0]); for(int i=1;i<=que[0];i++) printf("%d ",que[i]);
	}
	else{
		printf("%d\n",que[0]-1); for(int i=2;i<=que[0];i++) printf("%d ",que[i]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,m,op,tot,w[N],f[N],fs[N],fa[N],que[N];
struct edge{int u,v,t;}edg[N];
inline int read(){
    int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
    while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
inline int find(int u){
	if(f[u]==u) return f[u]; return f[u]=find(f[u]);
}
inline void addedge(int u,int v){
	tot++,edg[tot].u=u,edg[tot].v=v,edg[tot].t=fs[u],fs[u]=tot;
}
inline void dfsit(int u){
	que[++que[0]]=u; bool fl=false;
	for(int i=fs[u];i>0;i=edg[i].t){
		int x=edg[i].v; if(fa[u]==x) continue; fa[x]=u,dfsit(x); fl=true;
	}
	if(w[u]&&u!=op) w[u]^=1,w[fa[u]]^=1,que[++que[0]]=fa[u],que[++que[0]]=u; if(fa[u]) que[++que[0]]=fa[u],w[fa[u]]^=1;
}
int main(){
	n=read(),m=read(); int u,v;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=m;i++){
		u=read(),v=read(); f[u]=find(u),f[v]=find(v); if(f[u]==f[v]) continue;
		addedge(u,v),addedge(v,u),f[f[u]]=f[v];
	}
	for(int i=1;i<=n;i++) w[i]=read()^1;
	for(int i=1;i<=n;i++){
		if(!w[i]){
			if(!op) op=find(i);
			if(find(i)!=op){
				puts("-1"); return 0;}
		}
	}
	if(!op){puts("0"); return 0;}
	dfsit(op);
	if(!w[op]){
		printf("%d\n",que[0]); for(int i=1;i<=que[0];i++) printf("%d ",que[i]);
	}
	else{
		printf("%d\n",que[0]-1); for(int i=2;i<=que[0];i++) printf("%d ",que[i]);
	}
	return 0;
}