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 = 100005, M = 6000005;
int n, sz[N], fa[N], hson[N], dep[N], top[N], id[N], idx;
vector<int> v[N];
void dfs1(int pos, int f) {
  fa[pos] = f;
  dep[pos] = dep[f] + 1;
  sz[pos] = 1;
  for (auto &i : v[pos])
    if (i != f) {
      dfs1(i, pos);
      sz[pos] += sz[i];
      if (sz[i] > sz[hson[pos]]) hson[pos] = i;
    }
}
void dfs2(int pos, int tp) {
  top[pos] = tp;
  id[pos] = ++idx;
  if (!hson[pos]) return;
  dfs2(hson[pos], tp);
  for (auto &i : v[pos])
    if (i != fa[pos] && i != hson[pos]) dfs2(i, i);
}
vector<int> vv[N << 2], e[M];
int ptr, dfn[M], clr[M], low[M], tidx;
inline void add(int x, int y) {
  e[x].push_back(y);
  e[y ^ 1].push_back(x ^ 1);
}
inline int lc(int pos) { return pos << 1; }
inline int rc(int pos) { return pos << 1 | 1; }
void tmodify(int pos, int l, int r, int ql, int qr, int w) {
  if (l == ql && r == qr) return vv[pos].push_back(w);
  int mid = (l + r) >> 1;
  if (qr <= mid)
    tmodify(lc(pos), l, mid, ql, qr, w);
  else if (ql > mid)
    tmodify(rc(pos), mid + 1, r, ql, qr, w);
  else
    tmodify(lc(pos), l, mid, ql, mid, w),
        tmodify(rc(pos), mid + 1, r, mid + 1, qr, w);
}
void modify(int x, int y, int w) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    tmodify(1, 1, n, id[top[x]], id[x], w);
    x = fa[top[x]];
  }
  if (x != y) {
    if (dep[x] < dep[y]) swap(x, y);
    tmodify(1, 1, n, id[y] + 1, id[x], w);
  }
}
void build(int pos, int l, int r, int p) {
  int len = vv[pos].size(), u = ++ptr, v = (ptr += len);
  if (len)
    add((v - 1) * 2, v * 2);
  else if (p)
    add(p * 2, v * 2);
  for (int i = 0; i < len; i++) {
    add(vv[pos][i], (u + i) * 2);
    if (i > 0)
      add((u + i - 1) * 2, (u + i) * 2), add((u + i - 1) * 2, vv[pos][i] ^ 1);
    else if (p)
      add(p << 1, u << 1), add(p << 1, vv[pos][i] ^ 1);
  }
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(lc(pos), l, mid, v);
  build(rc(pos), mid + 1, r, v);
}
int stk[M], tp, cc;
void tarjan(int pos) {
  dfn[pos] = low[pos] = ++tidx;
  stk[++tp] = pos;
  for (auto &i : e[pos])
    if (!dfn[i])
      tarjan(i), low[pos] = min(low[pos], low[i]);
    else if (!clr[i])
      low[pos] = min(low[pos], dfn[i]);
  if (dfn[pos] == low[pos]) {
    clr[pos] = ++cc;
    while (stk[tp] != pos) clr[stk[tp--]] = cc;
    --tp;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    v[t1].push_back(t2);
    v[t2].push_back(t1);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    modify(t1, t2, i * 2);
    cin >> t1 >> t2;
    modify(t1, t2, i * 2 + 1);
  }
  ptr = m;
  build(1, 1, n, 0);
  for (int i = ptr * 2; i > 0; --i)
    if (!clr[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (clr[i * 2] == clr[i * 2 + 1]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  for (int i = 1; i <= m; i++) puts(clr[i * 2] < clr[i * 2 + 1] ? "1" : "2");
  return 0;
}