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 mxN = 1e5 + 2;
int n, m, ui, vi, p[mxN], d[mxN], pr[mxN], hv[mxN], ap[mxN], var[2 * mxN];
vector<int> adj[mxN], seg[2 * mxN];
template <int SZ>
struct twosat {
  int n, c[2 * SZ];
  vector<int> a1[2 * SZ], a2[2 * SZ], st;
  bool vis[2 * SZ], ans[SZ];
  int newVar() { return n++; }
  void implies(int u, int v) {
    a1[u].push_back(v);
    a1[v ^ 1].push_back(u ^ 1);
  }
  void dfs1(int u) {
    vis[u] = 1;
    for (int v : a1[u])
      if (!vis[v]) dfs1(v);
    st.push_back(u);
  }
  void dfs2(int u, int cu) {
    vis[u] = 0;
    c[u] = cu;
    for (int v : a2[u])
      if (vis[v]) dfs2(v, cu);
  }
  bool ac() {
    for (int i = 0; i < 2 * n; ++i)
      if (!vis[i]) dfs1(i);
    for (int i = 0; i < 2 * n; ++i)
      for (int j : a1[i]) a2[j].push_back(i);
    for (int i = 2 * n - 1; i >= 0; --i)
      if (vis[st[i]]) dfs2(st[i], i);
    for (int i = 0; i < 2 * n; i += 2) {
      if (c[i] == c[i ^ 1]) return 0;
      ans[i / 2] = c[i] < c[i ^ 1];
    }
    return 1;
  }
};
twosat<(int)7e5> T;
int dfs(int u = 1, int pu = -1) {
  int s = 1, mcs = 0;
  p[u] = pu;
  d[u] = pu == -1 ? 0 : d[pu] + 1;
  for (int v : adj[u]) {
    if (v == pu) continue;
    int cs = dfs(v, u);
    if (cs > mcs) {
      hv[u] = v;
      mcs = cs;
    }
    s += cs;
  }
  return s;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> ui >> vi;
    adj[ui].push_back(vi);
    adj[vi].push_back(ui);
  }
  memset(hv, -1, 4 * n);
  dfs();
  for (int i = 1, j = 0; i <= n; ++i) {
    if (i != 1 && hv[p[i]] == i) continue;
    for (int k = i; k != -1; k = hv[k]) {
      pr[k] = i;
      ap[k] = j++;
    }
  }
  cin >> m;
  for (int i = 0; i < 2 * m; ++i) {
    cin >> ui >> vi;
    auto upd = [&](int l, int r) {
      for (l += n, r += n + 1; l < r; ++l /= 2, r /= 2) {
        if (l & 1) seg[l].push_back(i);
        if (r & 1) seg[r - 1].push_back(i);
      }
    };
    for (; pr[ui] != pr[vi]; ui = p[pr[ui]]) {
      if (d[pr[ui]] < d[pr[vi]]) swap(ui, vi);
      upd(ap[pr[ui]], ap[ui]);
    }
    if (d[ui] > d[vi]) swap(ui, vi);
    upd(ap[ui] + 1, ap[vi]);
  }
  T.n = m;
  for (int i = 1; i < 2 * n; i++) {
    for (auto j : seg[i]) {
      if (var[i]) {
        T.implies(j, 2 * var[i] + 1);
        T.implies(2 * var[i], 2 * T.n);
      }
      T.implies(j, 2 * T.n);
      var[i] = T.newVar();
    }
    if (i < n) {
      var[2 * i] = var[2 * i + 1] = var[i];
    }
  }
  if (!T.ac()) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < m; ++i) cout << 2 - T.ans[i] << "\n";
}