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;
const int inf = 1e9;
const long long Inf = 1e18;
const int N = 2e6 + 10;
const int mod = 0;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
struct edge {
  int to, nxt;
} e[N << 1];
int tot = 1, h[N];
void adde(int u, int v) {
  e[++tot] = (edge){v, h[u]};
  h[u] = tot;
  e[++tot] = (edge){u, h[v]};
  h[v] = tot;
}
int n, m, fa[N], son[N], siz[N], dep[N], top[N], dfn[N],
    tim = 0, cnt = 0, L[N], R[N], st[N], tp = 0, low[N], in[N], scc = 0, bel[N];
vector<int> tr[N], E[N];
void addlim(int u, int v) {
  E[u].push_back(v);
  E[v ^ 1].push_back(u ^ 1);
}
void dfs1(int u, int ff) {
  siz[u] = 1;
  fa[u] = ff;
  dep[u] = dep[ff] + 1;
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == ff) continue;
    dfs1(v, u);
    siz[u] += siz[v];
    if (siz[son[u]] < siz[v]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  dfn[u] = ++tim;
  if (son[u]) dfs2(son[u], tp);
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
void insert(int o, int l, int r, int L, int R, int id) {
  if (L <= l && r <= R) {
    tr[o].push_back(id);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) insert((o << 1), l, mid, L, R, id);
  if (R > mid) insert((o << 1 | 1), mid + 1, r, L, R, id);
}
void build(int o, int l, int r) {
  L[o] = ++cnt;
  cnt += int(tr[o].size());
  R[o] = cnt;
  if (o > 1) addlim(R[o >> 1] << 1, L[o] << 1);
  for (int i = 0; i < int(tr[o].size()); i++) {
    addlim((L[o] + i) << 1, tr[o][i] ^ 1);
    addlim((L[o] + i) << 1, (L[o] + i + 1) << 1);
    addlim(tr[o][i], (L[o] + i + 1) << 1);
  }
  if (l == r) return;
  int mid = (l + r) >> 1;
  build((o << 1), l, mid);
  build((o << 1 | 1), mid + 1, r);
}
void ins(int u, int v, int id) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    insert(1, 1, n, dfn[top[u]], dfn[u], id);
    u = fa[top[u]];
  }
  if (dfn[u] > dfn[v]) swap(u, v);
  if (dfn[u] < dfn[v]) insert(1, 1, n, dfn[u] + 1, dfn[v], id);
}
void tarjan(int u) {
  dfn[u] = low[u] = ++tim;
  st[++tp] = u;
  in[u] = 1;
  for (int v : E[u]) {
    if (!dfn[v])
      tarjan(v), low[u] = min(low[u], low[v]);
    else if (in[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    int v;
    ++scc;
    do v = st[tp--], bel[v] = scc, in[v] = 0;
    while (u != v);
  }
}
int main() {
  cin >> n;
  for (int i = 1, u, v; i < n; i++) u = gi(), v = gi(), adde(u, v);
  dfs1(1, 0);
  dfs2(1, 1);
  cin >> m;
  for (int i = 1, a, b, c, d; i <= m; i++) {
    a = gi(), b = gi(), c = gi(), d = gi();
    ins(a, b, i << 1), ins(c, d, i << 1 | 1);
  }
  cnt = m;
  build(1, 1, n);
  memset(dfn, 0, sizeof(dfn));
  tim = 0;
  n = cnt << 1 | 1;
  for (int i = 2; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= cnt; i++)
    if (bel[i << 1] == bel[i << 1 | 1]) return puts("NO"), 0;
  puts("YES");
  for (int i = 1; i <= m; i++)
    if (bel[i << 1] < bel[i << 1 | 1])
      puts("1");
    else
      puts("2");
  return 0;
}