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 std::cerr;
using std::endl;
const int N = 1.5e6 + 233;
int n, m;
std::vector<int> G[N];
int fa[N], son[N], size[N], top[N], dep[N], id[N], num;
void dfs1(int x, int dad) {
  fa[x] = dad, dep[x] = dep[dad] + 1, size[x] = 1;
  for (int y : G[x])
    if (y != dad) {
      dfs1(y, x);
      if (size[son[x]] < size[y]) son[x] = y;
      size[x] += size[y];
    }
}
void dfs2(int x, int topf) {
  top[x] = topf, id[x] = ++num;
  if (son[x]) dfs2(son[x], topf);
  for (int y : G[x])
    if (y != fa[x] && y != son[x]) dfs2(y, y);
}
int tot;
std::vector<int> seg[N];
inline void addedge(int x, int y) {
  G[x].push_back(y), G[y ^ 1].push_back(x ^ 1);
}
void modify(int p, int l, int r, int v, int L, int R) {
  if (l <= L && r >= R) return seg[p].push_back(v), void();
  if (l <= ((L + R) >> 1)) modify((p << 1), l, r, v, L, ((L + R) >> 1));
  if (r > ((L + R) >> 1))
    modify(((p << 1) | 1), l, r, v, ((L + R) >> 1) + 1, R);
}
void build(int p, int L, int R, int last) {
  int l = ++tot, r = tot + seg[p].size();
  tot = r;
  if (seg[p].empty()) {
    if (last) addedge(last * 2, l * 2);
  } else {
    addedge((r - 1) * 2, r * 2);
  }
  for (int i = 0; i < (int)seg[p].size(); ++i) {
    int id = seg[p][i];
    if (i > 0)
      addedge((l + i - 1) * 2, (l + i) * 2);
    else if (last)
      addedge(last * 2, l * 2);
    addedge(id, (l + i) * 2);
    if (i > 0)
      addedge((l + i - 1) * 2, id ^ 1);
    else if (last)
      addedge(last * 2, id ^ 1);
  }
  if (L != R) {
    build((p << 1), L, ((L + R) >> 1), r);
    build(((p << 1) | 1), ((L + R) >> 1) + 1, R, r);
  }
}
inline void insert(int a, int b, int v) {
  while (top[a] != top[b]) {
    if (dep[top[a]] < dep[top[b]]) std::swap(a, b);
    modify(1, id[top[a]], id[a], v, 2, n);
    a = fa[top[a]];
  }
  if (a == b) return;
  if (dep[a] > dep[b]) std::swap(a, b);
  modify(1, id[a] + 1, id[b], v, 2, n);
}
int dfn[N], low[N], baka, stk[N], stop, ins[N], cnt, bel[N];
void tarjan(int x) {
  dfn[x] = low[x] = ++baka;
  stk[++stop] = x, ins[x] = 1;
  for (int y : G[x]) {
    if (!dfn[y]) {
      tarjan(y);
      low[x] = std::min(low[x], low[y]);
    } else if (ins[y])
      low[x] = std::min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    int y;
    ++cnt;
    do {
      y = stk[stop--];
      ins[y] = 0;
      bel[y] = cnt;
    } while (x != y);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    G[x].push_back(y), G[y].push_back(x);
  }
  dfs1(1, 0), dfs2(1, 1);
  for (int i = 1; i <= n; ++i) G[i].clear();
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    insert(a, b, i * 2);
    insert(c, d, i * 2 + 1);
  }
  tot = m;
  build(1, 2, n, 0);
  for (int i = 1; i <= tot * 2 + 1; ++i)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; ++i)
    if (bel[i * 2] == bel[i * 2 + 1]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  for (int i = 1; i <= m; ++i) {
    printf("%d\n", (bel[i * 2] > bel[i * 2 + 1]) + 1);
  }
  return 0;
}