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 read() {
  int s = 0, t = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * t;
}
const int N = 1e5 + 5;
const int M = 6e6 + 5;
int n, m, num, tot, Num;
int prt[N], d[N], sz[N], son[N], top[N], p[N];
int dfn[M], low[M], s[M], vis[M], b[M];
vector<int> G[M], S[N << 2];
void DFS1(int x, int f) {
  prt[x] = f, d[x] = d[f] + 1, sz[x] = 1;
  for (auto y : G[x])
    if (y ^ f) {
      DFS1(y, x), sz[x] += sz[y];
      if (sz[y] > sz[son[x]]) son[x] = y;
    }
}
void DFS2(int x, int tp) {
  top[x] = tp, p[x] = ++p[0];
  if (son[x]) DFS2(son[x], tp);
  for (auto y : G[x])
    if ((y ^ prt[x]) && (y ^ son[x])) DFS2(y, y);
}
void Ins(int x, int l, int r, int ql, int qr, int v) {
  if (ql <= l && r <= qr) {
    S[x].push_back(v);
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) Ins(x << 1, l, mid, ql, qr, v);
  if (qr > mid) Ins(x << 1 | 1, mid + 1, r, ql, qr, v);
}
void Upd(int x, int y, int v) {
  while (top[x] ^ top[y]) {
    if (d[top[x]] < d[top[y]]) swap(x, y);
    Ins(1, 1, n, p[top[x]], p[x], v), x = prt[top[x]];
  }
  if (d[x] > d[y]) swap(x, y);
  if (x ^ y) Ins(1, 1, n, p[x] + 1, p[y], v);
}
void Add(int x, int y) { G[x].push_back(y), G[y ^ 1].push_back(x ^ 1); }
void Build(int x, int l, int r, int p) {
  for (int i = 0; i < S[x].size(); i++) {
    int t = S[x][i];
    tot++;
    if (p) Add(p * 2, tot * 2), Add(p * 2, t ^ 1);
    p = tot, Add(t, tot * 2);
  }
  if (l == r) return;
  int mid = (l + r) >> 1;
  Build(x << 1, l, mid, p), Build(x << 1 | 1, mid + 1, r, p);
}
void Tarjan(int x) {
  dfn[x] = low[x] = ++dfn[0], vis[x] = 1, s[++num] = x;
  for (auto y : G[x]) {
    if (!dfn[y]) {
      Tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (vis[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    Num++;
    for (int y = 0; y ^ x;) b[y = s[num--]] = Num, vis[y] = 0;
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    G[x].push_back(y), G[y].push_back(x);
  }
  DFS1(1, 0), DFS2(1, 1);
  m = read();
  for (int i = 1; i <= m; i++) {
    Upd(read(), read(), i * 2);
    Upd(read(), read(), i * 2 + 1);
  }
  for (int i = 1; i <= n; i++) G[i].clear();
  tot = m, Build(1, 1, n, 0);
  for (int i = 1; i <= 2 * tot + 1; i++)
    if (!dfn[i]) Tarjan(i);
  for (int i = 1; i <= m; i++)
    if (b[i << 1] == b[i << 1 | 1]) return puts("No"), 0;
  puts("Yes");
  for (int i = 1; i <= m; i++)
    cout << ((b[i << 1] < b[i << 1 | 1]) ? 1 : 2) << '\n';
  return 0;
}