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>
const int MAXN = 100010;
const int MAXM = 10010;
const int MAXP = MAXM * 100 * 3;
const int MAXE = MAXP * 4;
namespace sat {
int head[MAXP], nxt[MAXE], to[MAXE], tot;
void adde(int b, int e) {
  if (!b || !e) return;
  nxt[++tot] = head[b];
  to[head[b] = tot] = e;
}
int dfn[MAXP], low[MAXP], bel[MAXP], idx, t0t;
int st[MAXP], top;
bool ins[MAXP];
void tarjan(int u) {
  dfn[u] = low[u] = ++t0t;
  ins[st[++top] = u] = true;
  for (int i = head[u]; i; i = nxt[i])
    if (!dfn[to[i]]) {
      tarjan(to[i]);
      low[u] = std::min(low[u], low[to[i]]);
    } else if (ins[to[i]])
      low[u] = std::min(low[u], dfn[to[i]]);
  if (dfn[u] == low[u]) {
    int v;
    ++idx;
    do ins[v = st[top--]] = false, bel[v] = idx;
    while (v != u);
  }
}
void solve(int n) {
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i);
}
}  // namespace sat
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void adde(int b, int e) {
  nxt[++tot] = head[b];
  to[head[b] = tot] = e;
  nxt[++tot] = head[e];
  to[head[e] = tot] = b;
}
int dep[MAXN], fa[MAXN], sz[MAXN], top[MAXN], son[MAXN], dfn[MAXN];
int t0t;
void dfs(int u) {
  sz[u] = 1;
  for (int i = head[u]; i; i = nxt[i])
    if (to[i] != fa[u]) {
      dep[to[i]] = dep[u] + 1;
      fa[to[i]] = u;
      dfs(to[i]);
      sz[u] += sz[to[i]];
      if (sz[to[i]] > sz[son[u]]) son[u] = to[i];
    }
}
void hld(int u) {
  dfn[u] = ++t0t;
  if (son[u]) top[son[u]] = top[u], hld(son[u]);
  for (int i = head[u]; i; i = nxt[i])
    if (to[i] != fa[u] && to[i] != son[u]) top[to[i]] = to[i], hld(to[i]);
}
int n, m, idx, ps[MAXM][2], alt[MAXM << 1];
std::vector<int> hav[MAXN << 2];
void link(int u, int l, int r, int L, int R, int t) {
  if (L <= l && r <= R) return (void)hav[u].push_back(t);
  int mid = l + r >> 1;
  if (L <= mid) link(u << 1, l, mid, L, R, t);
  if (mid < R) link(u << 1 | 1, mid + 1, r, L, R, t);
}
void link(int x, int y, int t) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) std::swap(x, y);
    link(1, 1, n, dfn[top[x]], dfn[x], t), x = fa[top[x]];
  }
  if (dep[x] > dep[y]) std::swap(x, y);
  if (x != y) link(1, 1, n, dfn[x] + 1, dfn[y], t);
}
std::pair<int, int> build(int u, int l, int r) {
  int in = ++idx, out = ++idx;
  if (l != r) {
    int mid = l + r >> 1;
    std::pair<int, int> t = build(u << 1, l, mid);
    sat::adde(in, t.first);
    sat::adde(t.second, out);
    t = build(u << 1 | 1, mid + 1, r);
    sat::adde(in, t.first);
    sat::adde(t.second, out);
  }
  const std::vector<int>& li = hav[u];
  const int S = li.size();
  int cur = 0;
  for (int i = 0; i <= S; ++i) {
    while (cur < i) {
      if (i != S && alt[li[cur]] == li[i]) break;
      sat::adde(++idx, in);
      sat::adde(idx, alt[li[cur]]);
      in = idx;
      sat::adde(out, ++idx);
      sat::adde(li[cur], idx);
      out = idx;
      ++cur;
    }
    if (i != S) {
      sat::adde(li[i], in);
      sat::adde(out, alt[li[i]]);
    }
  }
  return std::pair<int, int>(in, out);
}
int ansl[MAXM];
int main() {
  std::ios_base::sync_with_stdio(false), std::cin.tie(0);
  std::cin >> n;
  for (int i = 1, b, e; i < n; ++i) std::cin >> b >> e, adde(b, e);
  dfs(1);
  top[1] = 1;
  hld(1);
  std::cin >> m;
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j < 2; ++j) ps[i][j] = ++idx;
    for (int j = 0; j < 2; ++j) alt[ps[i][j]] = ps[i][j ^ 1];
  }
  for (int i = 1; i <= m; ++i) {
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    link(x1, y1, ps[i][0]);
    link(x2, y2, ps[i][1]);
  }
  build(1, 1, n);
  sat::solve(idx);
  bool can = true;
  for (int i = 1; i <= m; ++i) {
    int x = sat::bel[ps[i][0]], y = sat::bel[ps[i][1]];
    if (x == y) can = false;
    ansl[i] = x < y ? 1 : 2;
  }
  if (!can) return std::cout << "NO" << std::endl, 0;
  std::cout << "YES" << std::endl;
  for (int i = 1; i <= m; ++i) std::cout << ansl[i] << '\n';
  return 0;
}