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 N = 1e5 + 7;
const int M = 1e4 + 7;
int n, m, tot, cnt, ind, tp, num;
vector<int> ve[N], g[N << 2], pre[N << 2], suf[N << 2];
bool instack[N * 40];
int sta[N * 40], bl[N * 40], dfn[N * 40], low[N * 40];
int top[N], sz[N], dep[N], f[N], son[N];
int A[M], B[M], C[M], D[M], head[N * 40], nxt[N * 80], to[N * 80];
inline int bro(int x) { return x <= m ? x + m : x - m; }
inline void link(int x, int y) {
  nxt[++tot] = head[x];
  to[head[x] = tot] = y;
}
void dfs1(int x) {
  sz[x] = 1;
  dep[x] = dep[f[x]] + 1;
  for (auto to : ve[x])
    if (to != f[x]) {
      f[to] = x;
      dfs1(to);
      sz[x] += sz[to];
      if (sz[to] > sz[son[x]]) son[x] = to;
    }
}
void dfs2(int x) {
  dfn[x] = ++ind;
  if (!son[x]) return;
  top[son[x]] = top[x];
  dfs2(son[x]);
  for (auto to : ve[x])
    if (to != f[x] && to != son[x]) dfs2(top[to] = to);
}
void tarjan(int x) {
  dfn[x] = low[x] = ++ind;
  sta[++tp] = x;
  instack[x] = 1;
  for (int i = head[x]; i; i = nxt[i])
    if (!dfn[to[i]])
      tarjan(to[i]), low[x] = min(low[x], low[to[i]]);
    else if (instack[to[i]])
      low[x] = min(low[x], dfn[to[i]]);
  if (dfn[x] == low[x]) {
    ++num;
    int y;
    do y = sta[tp--], instack[y] = 0, bl[y] = num;
    while (y != x);
  }
}
void insert(int p, int id, int l, int r, int L, int R) {
  if (L >= l && R <= r) return g[p].push_back(id), void();
  const int mid = L + R >> 1;
  if (l <= mid) insert(p << 1, id, l, r, L, mid);
  if (r > mid) insert(p << 1 | 1, id, l, r, mid + 1, R);
}
void build(int p, int l, int r) {
  pre[p].resize(g[p].size() + 2);
  suf[p].resize(g[p].size() + 2);
  for (int i = 0; i < pre[p].size(); ++i) pre[p][i] = ++cnt;
  for (int i = 0; i < suf[p].size(); ++i) suf[p][i] = ++cnt;
  for (int i = 0; i < pre[p].size() - 1; ++i) link(pre[p][i + 1], pre[p][i]);
  for (int i = 0; i < suf[p].size() - 1; ++i) link(suf[p][i], suf[p][i + 1]);
  if (p ^ 1)
    link(pre[p][0], pre[p >> 1].back()), link(suf[p >> 1].back(), suf[p][0]);
  for (int i = 0; i < g[p].size(); ++i)
    link(g[p][i], pre[p][i]), link(g[p][i], suf[p][i + 2]),
        link(pre[p][i + 1], bro(g[p][i])), link(suf[p][i + 1], bro(g[p][i]));
  if (l == r) return;
  const int mid = l + r >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
}
void insert(int x, int y, int id) {
  while (top[x] ^ top[y])
    if (dep[top[x]] > dep[top[y]])
      insert(1, id, dfn[top[x]], dfn[x], 1, n), x = f[top[x]];
    else
      insert(1, id, dfn[top[y]], dfn[y], 1, n), y = f[top[y]];
  if (dfn[x] != dfn[y])
    insert(1, id, min(dfn[x], dfn[y]) + 1, max(dfn[x], dfn[y]), 1, n);
}
inline int read(register int x = 0, register char ch = getchar(),
                register int f = 0) {
  for (; !isdigit(ch); ch = getchar()) f = ch == '-';
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return f ? -x : x;
}
int main() {
  n = read();
  for (int i = 1, a, b; i < n; ++i)
    a = read(), b = read(), ve[a].push_back(b), ve[b].push_back(a);
  dfs1(1);
  dfs2(top[1] = 1);
  m = read();
  for (int i = 1; i <= m; ++i)
    A[i] = read(), B[i] = read(), C[i] = read(), D[i] = read(),
    insert(A[i], B[i], i), insert(C[i], D[i], i + m);
  cnt = 2 * m;
  build(1, 1, n);
  ind = 0;
  memset(dfn, 0, sizeof(dfn));
  for (int i = 1; i <= cnt; ++i)
    if (!dfn[i]) tarjan(i);
  int ok = 1;
  for (int i = 1; i <= m; ++i)
    if (bl[i] == bl[i + m]) ok = 0;
  if (!ok)
    puts("NO");
  else {
    puts("YES");
    for (int i = 1; i <= m; ++i) printf("%d\n", bl[i + m] < bl[i] ? 2 : 1);
  }
  return 0;
}