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;
template <typename T>
inline T read() {
  T x = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) f = c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 4e5 + 9;
int head[N], nex[N], to[N], cnt;
inline void add(int u, int v) {
  nex[++cnt] = head[u];
  head[u] = cnt, to[cnt] = v;
}
int siz[N], son[N], dep[N], fa[N];
inline void dfs1(int u, int _f) {
  siz[u] = 1, dep[u] = dep[_f] + 1, fa[u] = _f;
  for (int i = head[u]; i; i = nex[i]) {
    if (to[i] ^ _f) {
      dfs1(to[i], u), siz[u] += siz[to[i]];
      if (siz[to[i]] > siz[son[u]]) son[u] = to[i];
    }
  }
}
int dfn[N], num, rak[N], top[N];
inline void dfs2(int u, int tp) {
  rak[dfn[u] = ++num] = u, top[u] = tp;
  if (son[u]) dfs2(son[u], tp);
  for (int i = head[u]; i; i = nex[i])
    if (!dfn[to[i]]) dfs2(to[i], to[i]);
}
namespace Tar {
int head[N << 2], nex[N * 20], to[N * 20], cnt;
inline void add(int u, int v) {
  nex[++cnt] = head[u];
  assert(cnt < N * 20);
  head[u] = cnt, to[cnt] = v;
}
int dfn[N << 2], low[N << 2], ins[N << 2], num, bel[N << 2], col_cnt;
stack<int> S;
inline void tarjan(int u) {
  dfn[u] = low[u] = ++num, ins[u] = 1, S.push(u);
  for (int i = head[u]; i; i = nex[i]) {
    if (!dfn[to[i]]) {
      tarjan(to[i]);
      low[u] = min(low[u], low[to[i]]);
    } else if (ins[to[i]])
      low[u] = min(low[u], dfn[to[i]]);
  }
  if (dfn[u] == low[u]) {
    int y;
    col_cnt++;
    do {
      y = S.top();
      S.pop();
      bel[y] = col_cnt, ins[y] = 0;
    } while (y != u);
  }
}
}  // namespace Tar
int n, m;
namespace Seg {
int tot;
vector<int> d[N << 2];
inline void modify(int k, int l, int r, int _l, int _r, int v) {
  if (_l <= l && r <= _r) return d[k].push_back(v), void();
  if (_l <= ((l + r) >> 1)) modify((k << 1), l, ((l + r) >> 1), _l, _r, v);
  if (_r > ((l + r) >> 1))
    modify((k << 1 | 1), ((l + r) >> 1) + 1, r, _l, _r, v);
}
inline void build(int k, int l, int r, int las0, int las1, int las2) {
  for (int i = 0; i < d[k].size(); i++) {
    int tmp0 = ++tot, tmp1 = ++tot, p = d[k][i] > m ? d[k][i] - m : d[k][i] + m;
    Tar::add(d[k][i], tmp0), Tar::add(d[k][i], tmp1);
    if (las0) Tar::add(las0, tmp0), Tar::add(las0, p);
    if (las1) Tar::add(tmp1, las1);
    if (las2) Tar::add(tmp1, las2);
    las0 = tmp0, las1 = tmp1, las2 = p;
  }
  if (l == r) return;
  build((k << 1), l, ((l + r) >> 1), las0, las1, las2);
  build((k << 1 | 1), ((l + r) >> 1) + 1, r, las0, las1, las2);
}
}  // namespace Seg
inline void modify(int u, int v, int id) {
  while (top[u] ^ top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    Seg::modify(1, 1, n, dfn[top[u]], dfn[u], id);
    u = fa[top[u]];
  }
  if (dep[u] < dep[v]) swap(u, v);
  if (v ^ u) Seg::modify(1, 1, n, dfn[v] + 1, dfn[u], id);
}
int main() {
  n = read<int>();
  for (int i = 1; i < n; i++) {
    int u = read<int>(), v = read<int>();
    add(u, v), add(v, u);
  }
  dfs1(1, 0), dfs2(1, 0);
  m = read<int>(), Seg::tot = 2 * m;
  for (int i = 1; i <= m; i++) {
    int u = read<int>(), v = read<int>();
    modify(u, v, i);
    u = read<int>(), v = read<int>();
    modify(u, v, i + m);
  }
  Seg::tot = 2 * m, Seg::build(1, 1, n, 0, 0, 0);
  for (int i = 1; i <= 2 * m; i++)
    if (!Tar::dfn[i]) Tar::tarjan(i);
  for (int i = 1; i <= m; i++)
    if (Tar::bel[i] == Tar::bel[i + m]) return puts("NO"), 0;
  puts("YES");
  for (int i = 1; i <= m; i++)
    if (Tar::bel[i] < Tar::bel[i + m])
      puts("1");
    else
      puts("2");
  return 0;
}
}  // namespace run
int main() { return run::main(); }