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;
int n, m, color, N, p;
vector<int> tree[100005 << 2], e[100005], edge[6000005];
int size[100005], dfn[6000005], pos[100005], dep[100005], fa[100005],
    son[100005];
int col[6000005], topp, sta[6000005], low[6000005], tim, top[100005];
void add(int u, int v) {
  edge[u].push_back(v);
  edge[v ^ 1].push_back(u ^ 1);
}
void dfs1(int u, int f) {
  size[u] = 1;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == f) continue;
    fa[v] = u;
    dep[v] = dep[u] + 1;
    dfs1(v, u);
    size[u] += size[v];
    if (size[v] > size[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int pre) {
  top[u] = pre;
  pos[u] = ++N;
  if (son[u]) dfs2(son[u], pre);
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
void build(int l, int r, int root, int pre) {
  int L = ++p;
  p += tree[root].size();
  int R = p;
  if (L < R)
    add(R << 1 | 1, R - 1 << 1 | 1);
  else if (pre)
    add(L << 1 | 1, pre << 1 | 1);
  for (int i = 0; i < tree[root].size(); i++) {
    int v = tree[root][i];
    if (i > 0)
      add(L + i << 1 | 1, L + i - 1 << 1 | 1);
    else if (pre)
      add(L << 1 | 1, pre << 1 | 1);
    add(v, L + i << 1);
    if (i > 0)
      add(L + i - 1 << 1, v ^ 1);
    else if (pre)
      add(pre << 1, v ^ 1);
  }
  if (l < r) {
    build(l, l + r >> 1, root << 1, R);
    build((l + r >> 1) + 1, r, root << 1 | 1, R);
  }
}
void work(int l, int r, int L, int R, int x, int root) {
  if (l >= L && r <= R) {
    tree[root].push_back(x);
    return;
  }
  if (l > R || r < L) return;
  int mid = l + r >> 1;
  work(l, mid, L, R, x, root << 1);
  work(mid + 1, r, L, R, x, root << 1 | 1);
}
void change(int u, int v, int x) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    work(2, n, pos[top[u]], pos[u], x, 1);
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  if (pos[u] < pos[v]) work(2, n, pos[u] + 1, pos[v], x, 1);
}
void tarjan(int u) {
  sta[++topp] = u;
  dfn[u] = low[u] = ++tim;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (!col[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (dfn[u] == low[u]) {
    ++color;
    while (1) {
      int w = sta[topp--];
      col[w] = color;
      if (u == w) break;
    }
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  scanf("%d", &m);
  p = m;
  int a, b, c, d;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    change(a, b, i << 1);
    change(c, d, i << 1 | 1);
  }
  build(2, n, 1, 0);
  for (int i = 2; i <= (p << 1 | 1); i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (col[i << 1] == col[i << 1 | 1]) {
      printf("NO");
      return 0;
    }
  printf("YES\n");
  for (int i = 1; i <= m; i++)
    if (col[i << 1] < col[i << 1 | 1])
      printf("1\n");
    else
      printf("2\n");
  return 0;
}