func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 5;   struct edge {     int next, v;   } e[MAXN << 1];   int n, q, root, cnt, head[MAXN], dep[MAXN], anc[MAXN][30];   void addEdge(int x, int y) {     e[++cnt].v = y;     e[cnt].next = head[x];     head[x] = cnt;   }   void dfs(int x) {     for (int i = head[x]; i != -1; i = e[i].next) {       int y = e[i].v;       if (y == anc[x][0]) continue;       dep[y] = dep[x] + 1;       anc[y][0] = x;       dfs(y);     }   }   void init() {     cnt = 0;     root = 1;     memset(head, -1, sizeof(head));   }   int lca(int a, int b) {     if (dep[a] > dep[b]) swap(a, b);     int h = dep[b] - dep[a];     for (int i = 0; (1 << i) <= h; i++)       if ((1 << i) & h) b = anc[b][i];     if (a != b) {       for (int i = (int)log2(dep[a]); i >= 0; i--) {         if (anc[a][i] != anc[b][i]) {           a = anc[a][i];           b = anc[b][i];         }       }       a = anc[a][0];     }     return a;   }   int dist(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }   int main() {     init();     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       addEdge(x, y);       addEdge(y, x);     }     dep[root] = 0;     dfs(root);     for (int j = 1; (1 << j) <= n; j++) {       for (int i = 1; i <= n; i++) {         anc[i][j] = anc[anc[i][j - 1]][j - 1];       }     }     scanf( %d , &q);     for (int kk = 1; kk < 10; kk++) int jj = kk + 1;     for (int i = 1; i <= q; i++) {       int x, y, a, b, k;       scanf( %d %d %d %d %d , &x, &y, &a, &b, &k);       int temp1 = dist(a, b);       int temp2 = min(dist(a, x) + dist(y, b), dist(a, y) + dist(x, b)) + 1;       int ans = k + 1;       if (k % 2 == temp1 % 2) ans = min(ans, temp1);       if (k % 2 == temp2 % 2) ans = min(ans, temp2);       if (ans <= k)         puts( YES );       else         puts( NO );     }   }   