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;
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * f;
}
template <typename T>
inline void Max(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
inline void Min(T &a, T b) {
  if (a > b) a = b;
}
const int N = 1e5 + 7, Nd = 6e6 + 7;
int n, edc;
int head[N], ndc;
struct edge {
  int lst, to;
  edge() {}
  edge(int lst, int to) : lst(lst), to(to) {}
} e[N << 1];
void Add(int a, int b) {
  e[++edc] = edge(head[a], b), head[a] = edc;
  e[++edc] = edge(head[b], a), head[b] = edc;
}
vector<int> G[Nd];
void lim(int a, int b) { G[a].push_back(b), G[b ^ 1].push_back(a ^ 1); }
int fa[N], in[N], dep[N], top[N], son[N], zson[N], tim;
void dfs1(int u) {
  son[u] = 1;
  for (int(i) = head[(u)], (v) = e[(i)].to; (i);
       (i) = e[(i)].lst, (v) = e[(i)].to)
    if (v ^ fa[u]) {
      dep[v] = dep[u] + 1, fa[v] = u;
      dfs1(v);
      son[u] += son[v];
      if (son[v] > son[zson[u]]) zson[u] = v;
    }
}
void dfs2(int u, int from) {
  top[u] = from, in[u] = ++tim;
  if (zson[u]) dfs2(zson[u], from);
  for (int(i) = head[(u)], (v) = e[(i)].to; (i);
       (i) = e[(i)].lst, (v) = e[(i)].to)
    if (v ^ fa[u] && v ^ zson[u]) dfs2(v, v);
}
vector<int> path[N << 2];
int L[N << 2], R[N << 2];
void modify(int L, int R, int l, int r, int o, int id) {
  if (L <= l && r <= R) {
    path[o].push_back(id);
    return;
  }
  int mid = l + r >> 1;
  if (L <= mid) modify(L, R, l, mid, o << 1, id);
  if (R > mid) modify(L, R, mid + 1, r, o << 1 | 1, id);
}
void build(int l, int r, int o) {
  L[o] = ++ndc, ndc += path[o].size(), R[o] = ndc;
  if (o > 1) {
    lim(L[o] << 1 | 1, R[o >> 1] << 1 | 1);
    if (!path[o].empty()) {
      int x = path[o][0];
      lim(R[o >> 1] << 1, x ^ 1);
    }
  }
  for (int i = 0; i < path[o].size(); ++i) {
    int x = path[o][i];
    lim(L[o] + i << 1 | 1, x ^ 1);
    lim(L[o] + i + 1 << 1 | 1, L[o] + i << 1 | 1);
    if (i ^ 0) lim(L[o] + i - 1 << 1, x ^ 1);
  }
  if (l == r) return;
  int mid = l + r >> 1;
  build(l, mid, o << 1);
  build(mid + 1, r, o << 1 | 1);
}
void ins(int x, int y, int id) {
  for (; top[x] ^ top[y]; y = fa[top[y]]) {
    if (dep[top[x]] > dep[top[y]]) swap(x, y);
    modify(in[top[y]], in[y], 1, n, 1, id);
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (x ^ y) modify(in[x] + 1, in[y], 1, n, 1, id);
}
int low[Nd], pre[Nd], st[Nd], scc[Nd], scc_cnt, tp;
void tarjan(int u) {
  low[u] = pre[u] = ++tim;
  st[++tp] = u;
  for (auto v : G[u]) {
    if (!low[v]) {
      tarjan(v);
      Min(pre[u], pre[v]);
    } else if (!scc[v])
      Min(pre[u], low[v]);
  }
  if (low[u] == pre[u] && ++scc_cnt)
    for (int x = -1; x ^ u;) scc[x = st[tp--]] = scc_cnt;
}
int main() {
  n = gi();
  ndc = n;
  for (int(i) = (1); (i) <= (n - 1); ++(i)) Add(gi(), gi());
  dep[1] = 1, dfs1(1), dfs2(1, 1);
  int m = gi();
  for (int(i) = (1); (i) <= (m); ++(i)) {
    int a = gi(), b = gi(), c = gi(), d = gi();
    ins(a, b, i << 1);
    ins(c, d, i << 1 | 1);
  }
  build(1, n, 1);
  tim = 0;
  for (int i = 1; i <= ndc * 2 + 1; ++i)
    if (!scc[i]) tarjan(i);
  for (int(i) = (1); (i) <= (m); ++(i)) {
    if (scc[i << 1] == scc[i << 1 | 1]) return puts("NO"), 0;
  }
  puts("YES");
  for (int(i) = (1); (i) <= (m); ++(i)) {
    puts(scc[i << 1] < scc[i << 1 | 1] ? "1" : "2");
  }
  return 0;
}