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 + 5, M = 6e6 + 5;
int n, he[N], to[N << 1], ne[N << 1], fa[N], sn[N], sz[N], d[N], tp[N], ps[N],
    ct;
void dfs1(int x, int y) {
  fa[x] = y, d[x] = d[y] + 1, sz[x] = 1;
  for (int i = he[x], j; i; i = ne[i])
    if (j = to[i], j != y) {
      dfs1(j, x), sz[x] += sz[j];
      if (sz[j] > sz[sn[x]]) sn[x] = j;
    }
}
void dfs2(int x, int y) {
  tp[x] = y, ps[x] = ++ct;
  if (!sn[x]) return;
  dfs2(sn[x], y);
  for (int i = he[x], j; i; i = ne[i])
    if (j = to[i], j != fa[x] && j != sn[x]) dfs2(j, j);
}
vector<int> vc[N << 2], e[M];
int u, v, w, id, cl[M], dfn[M], low[M], c, z, st[M], t;
inline void add(int x, int y) { e[x].push_back(y), e[y ^ 1].push_back(x ^ 1); }
void upd(int k, int l, int r) {
  if (u <= l && r <= v) return vc[k].push_back(w);
  int m = l + r >> 1;
  if (u <= m) upd(k << 1, l, m);
  if (m < v) upd(k << 1 | 1, m + 1, r);
}
void mdf(int x, int y) {
  while (tp[x] != tp[y]) {
    if (d[tp[x]] < d[tp[y]]) swap(x, y);
    u = ps[tp[x]], v = ps[x], upd(1, 2, n), x = fa[tp[x]];
  }
  if (x != y) {
    if (d[x] < d[y]) swap(x, y);
    u = ps[y] + 1, v = ps[x], upd(1, 2, n);
  }
}
void build(int k, int l, int r, int p) {
  int o = vc[k].size(), i, j, u = ++id, v = (id += o);
  if (o)
    add(v - 1 << 1, v << 1);
  else if (p)
    add(p << 1, v << 1);
  for (i = 0; i < o; ++i) {
    j = vc[k][i], add(j, u + i << 1);
    if (i > 0)
      add(u + i - 1 << 1, u + i << 1), add(u + i - 1 << 1, j ^ 1);
    else if (p)
      add(p << 1, u << 1), add(p << 1, j ^ 1);
  }
  if (l == r) return;
  int m = l + r >> 1;
  build(k << 1, l, m, v), build(k << 1 | 1, m + 1, r, v);
}
void tarjan(int x) {
  dfn[x] = low[x] = ++z, st[++t] = x;
  for (auto j : e[x])
    if (!dfn[j])
      tarjan(j), low[x] = min(low[x], low[j]);
    else if (!cl[j])
      low[x] = min(low[x], dfn[j]);
  if (low[x] == dfn[x]) {
    cl[x] = ++c;
    while (st[t] != x) cl[st[t--]] = c;
    --t;
  }
}
int main() {
  int m, i, j, k, t = 0;
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &j, &k);
    ne[++t] = he[j], to[t] = k, he[j] = t;
    ne[++t] = he[k], to[t] = j, he[k] = t;
  }
  dfs1(1, 0), dfs2(1, 1), scanf("%d", &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &j, &k), w = i << 1, mdf(j, k);
    scanf("%d%d", &j, &k), w |= 1, mdf(j, k);
  }
  id = m, build(1, 2, n, 0);
  for (i = id << 1; i; --i)
    if (!cl[i]) tarjan(i);
  for (i = 1; i <= m; ++i)
    if (cl[i << 1] == cl[i << 1 | 1]) return puts("NO"), 0;
  puts("YES");
  for (i = 1; i <= m; ++i) puts(cl[i << 1] < cl[i << 1 | 1] ? "1" : "2");
  return 0;
}