Problem: There is a tree with n vertices. There are also m ants living on it. Each ant has its own color. The i-th ant has two favorite pairs of vertices: (a_i, b_i) and (c_i, d_i). You need to tell if it is possible to paint the edges of the tree in m colors so that every ant will be able to walk between vertices from one of its favorite pairs using only edges of his color; if it is possible, you need to print which pair every ant should use.

Input

The first line contains a single integer n (2 ≤ n ≤ 10^5) — the number of vertices.

Each of the next n-1 lines contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n), meaning that there is an edge between vertices u_i and v_i.

The next line contains a single integer m (1 ≤ m ≤ 10^4) — the number of ants.

Each of the next m lines contains four integers a_i, b_i, c_i, and d_i (1 ≤ a_i, b_i, c_i, d_i ≤ n, a_i ≠ b_i, c_i ≠ d_i), meaning that pairs (a_i, b_i) and (c_i, d_i) are favorite for the i-th ant.

Output

Print "NO" (without quotes) if the wanted painting is impossible.

Otherwise, print "YES" (without quotes). Print m lines. On the i-th line, print 1 if the i-th ant will use the first pair and 2 otherwise. If there are multiple answers, print any.

Examples

Input

6
1 2
3 1
4 1
5 2
6 2
3
2 6 3 4
1 6 6 5
1 4 5 2


Output

YES
2
1
2


Input

5
1 2
1 3
1 4
1 5
2
2 3 4 5
3 4 5 2


Output

NO

Note

In the sample, the second and the third edge should be painted in the first color, the first and the fifth should be painted in the second color, and the fourth should be painted in the third color.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int op(int x) { return ((x & 1) ? x + 1 : x - 1); }
struct Edge {
  int t, next;
  Edge() {}
  Edge(int a, int b) : t(a), next(b) {}
};
int ans[10005];
namespace Graph {
Edge e[10000000];
int head[2000000], tot, node_cnt;
void addEdge(int x, int y) {
  e[++tot] = Edge(y, head[x]);
  head[x] = tot;
}
int dfn[2000000], low[2000000], dfs_cnt;
int st[2000000], top;
bool in[2000000];
int id[2000000], scc_cnt;
void dfs(int x) {
  dfn[x] = low[x] = ++dfs_cnt;
  st[++top] = x;
  in[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int u = e[i].t;
    if (!dfn[u]) {
      dfs(u);
      low[x] = min(low[x], low[u]);
    } else if (in[u])
      low[x] = min(low[x], dfn[u]);
  }
  if (low[x] >= dfn[x]) {
    int t;
    scc_cnt++;
    do {
      t = st[top--];
      in[t] = 0;
      id[t] = scc_cnt;
    } while (t != x);
  }
}
bool solve(int n) {
  for (int i = 1; i <= node_cnt; i++)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (id[2 * i - 1] == id[2 * i]) return 0;
  for (int i = 1; i <= n; i++) ans[i] = ((id[2 * i - 1] < id[2 * i]) ? 1 : 2);
  return 1;
}
}  // namespace Graph
namespace SGT {
vector<int> vt[400000];
void update(int l, int r, int o, int lx, int rx, int p) {
  if (l >= lx && r <= rx)
    vt[o].push_back(p);
  else {
    int m = ((l + r) >> 1);
    if (m >= lx) update(l, m, o * 2, lx, rx, p);
    if (m < rx) update(m + 1, r, o * 2 + 1, lx, rx, p);
  }
}
vector<int> pre[400000], suf[400000];
void dfs(int l, int r, int o) {
  int n = vt[o].size();
  pre[o].resize(n);
  suf[o].resize(n);
  for (int i = 0; i < n; i++) {
    pre[o][i] = ++Graph::node_cnt;
    suf[o][i] = ++Graph::node_cnt;
  }
  for (int i = 0; i < n; i++) {
    int x = vt[o][i];
    Graph::addEdge(pre[o][i], op(x));
    Graph::addEdge(suf[o][i], op(x));
    if (i > 0) {
      Graph::addEdge(pre[o][i], pre[o][i - 1]);
      Graph::addEdge(x, pre[o][i - 1]);
    }
    if (i < n - 1) {
      Graph::addEdge(suf[o][i], suf[o][i + 1]);
      Graph::addEdge(x, suf[o][i + 1]);
    }
  }
  if (!n) {
    n = 1;
    pre[o].resize(1);
    suf[o].resize(1);
    pre[o][0] = ++Graph::node_cnt;
    suf[o][0] = ++Graph::node_cnt;
  }
  if (l == r)
    return;
  else {
    int m = ((l + r) >> 1);
    dfs(l, m, o * 2);
    dfs(m + 1, r, o * 2 + 1);
    Graph::addEdge(pre[o * 2][0], pre[o][n - 1]);
    Graph::addEdge(suf[o][n - 1], suf[o * 2][0]);
    Graph::addEdge(pre[o * 2 + 1][0], pre[o][n - 1]);
    Graph::addEdge(suf[o][n - 1], suf[o * 2 + 1][0]);
    if (vt[o].size()) {
      Graph::addEdge(vt[o][n - 1], suf[o * 2][0]);
      Graph::addEdge(vt[o][n - 1], suf[o * 2 + 1][0]);
    }
    if (vt[o * 2].size()) Graph::addEdge(vt[o * 2][0], pre[o][n - 1]);
    if (vt[o * 2 + 1].size()) Graph::addEdge(vt[o * 2 + 1][0], pre[o][n - 1]);
  }
}
}  // namespace SGT
namespace HLD {
Edge e[200005];
int head[100005], tot;
void addEdge(int x, int y) {
  e[++tot] = Edge(y, head[x]);
  head[x] = tot;
  e[++tot] = Edge(x, head[y]);
  head[y] = tot;
}
int fa[100005], dep[100005];
int size[100005], son[100005];
void dfs1(int x) {
  size[x] = 1;
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].t != fa[x]) {
      int u = e[i].t;
      fa[u] = x;
      dep[u] = dep[x] + 1;
      dfs1(u);
      size[x] += size[u];
      if (size[u] > size[son[x]]) son[x] = u;
    }
}
int dfn[100005], top[100005], dfs_cnt;
void dfs2(int x, int anc) {
  dfn[x] = ++dfs_cnt;
  top[x] = anc;
  if (son[x]) dfs2(son[x], anc);
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].t != fa[x] && e[i].t != son[x]) dfs2(e[i].t, e[i].t);
}
void build() {
  dfs1(1);
  dfs2(1, 1);
}
void update(int x, int y, int id, int n) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    SGT::update(1, n, 1, dfn[top[x]], dfn[x], id);
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (dfn[x] < dfn[y]) SGT::update(1, n, 1, dfn[x] + 1, dfn[y], id);
}
}  // namespace HLD
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    HLD::addEdge(x, y);
  }
  HLD::build();
  int m;
  scanf("%d", &m);
  Graph::node_cnt = 2 * m;
  for (int i = 1; i <= m; i++) {
    int x1, yy, x2, y2;
    scanf("%d%d%d%d", &x1, &yy, &x2, &y2);
    HLD::update(x1, yy, 2 * i - 1, n);
    HLD::update(x2, y2, 2 * i, n);
  }
  SGT::dfs(1, n, 1);
  if (!Graph::solve(m)) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}