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;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s;
}
const int N = 1e5 + 5, M = 5e6 + 5;
int n, m;
vector<int> G[N];
int dfn[N], top[N], siz[N], fa[N], dep[N], son[N], dfn_t;
int tot;
struct Sat {
  vector<int> G[M];
  int dfn[M], low[M], bel[M], t;
  int stk[M], top, cnt;
  bool instk[M];
  inline void add(int x, int y) {
    G[x].push_back(y);
    G[y ^ 1].push_back(x ^ 1);
  }
  void tarjan(int u) {
    dfn[u] = low[u] = ++t;
    stk[++top] = u;
    instk[u] = 1;
    for (int v : G[u]) {
      if (!dfn[v])
        tarjan(v), low[u] = min(low[u], low[v]);
      else if (instk[v])
        low[u] = min(low[u], dfn[v]);
    }
    if (dfn[u] == low[u]) {
      bel[u] = ++cnt;
      instk[u] = 0;
      while (stk[top] != u) {
        bel[stk[top]] = cnt;
        instk[stk[top--]] = 0;
      }
      top--;
    }
  }
  void solve() {
    for (int i = tot * 2; i >= 1; i--)
      if (!bel[i]) tarjan(i);
    for (int i = 1; i <= m; i++)
      if (bel[i * 2] == bel[i * 2 + 1]) {
        puts("NO");
        return;
      }
    puts("YES");
    for (int i = 1; i <= m; i++)
      if (bel[i * 2] < bel[i * 2 + 1])
        puts("1");
      else
        puts("2");
  }
} T;
void dfs1(int u, int f) {
  siz[u] = 1, dep[u] = dep[f] + 1, fa[u] = f;
  for (int v : G[u]) {
    if (v == f) continue;
    dfs1(v, u);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int k) {
  top[u] = k;
  dfn[u] = ++dfn_t;
  if (!son[u]) return;
  dfs2(son[u], k);
  for (int v : G[u])
    if (v != fa[u] && v != son[u]) dfs2(v, v);
}
vector<int> vec[N << 2];
inline void update(int rt, int l, int r, int L, int R, int v) {
  if (L <= l && r <= R) {
    vec[rt].push_back(v);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) update(rt << 1, l, mid, L, R, v);
  if (R > mid) update(rt << 1 | 1, mid + 1, r, L, R, v);
}
inline void modify(int u, int v, int w) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    update(1, 2, n, dfn[top[u]], dfn[u], w);
    u = fa[top[u]];
  }
  if (u != v) {
    if (dep[u] > dep[v]) swap(u, v);
    update(1, 2, n, dfn[u] + 1, dfn[v], w);
  }
}
void build(int rt, int l, int r, int p) {
  int u = ++tot, v = tot + vec[rt].size();
  tot += vec[rt].size();
  if (vec[rt].size())
    T.add((v - 1) * 2, v * 2);
  else if (p)
    T.add(p * 2, v * 2);
  for (int i = 0; i < vec[rt].size(); i++) {
    int j = vec[rt][i];
    T.add(j, (u + i) * 2);
    if (i > 0)
      T.add((u + i - 1) * 2, (u + i) * 2), T.add((u + i - 1) * 2, j ^ 1);
    else if (p)
      T.add(p * 2, u * 2), T.add(p * 2, j ^ 1);
  }
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid, v);
  build(rt << 1 | 1, mid + 1, r, v);
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) reverse(G[i].begin(), G[i].end());
  dfs1(1, 0);
  dfs2(1, 1);
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    modify(u, v, i * 2);
    u = read(), v = read();
    modify(u, v, i * 2 + 1);
  }
  tot = m;
  build(1, 2, n, 0);
  T.solve();
  return 0;
}