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;
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
const int INF = 1e9 + 7, N = 1e5 + 7;
struct Two_SAT {
  int n;
  vector<pair<int, int> > edges;
  void init(int num_of_var) {
    n = num_of_var * 2;
    edges.clear();
  }
  int add_var() { return (n += 2) - 2; }
  int neg(int u) { return u ^ 1; };
  void either(int u, int v) {
    edges.emplace_back(neg(u), v);
    edges.emplace_back(neg(v), u);
  }
  void implies(int u, int v) { either(neg(u), v); }
  int yes(int x) { return 2 * x; }
  vector<vector<int> > G, rG;
  vector<int> scc, order;
  vector<bool> vis, ans;
  void dfs(int u) {
    vis[u] = 1;
    for (int v : rG[u])
      if (!vis[v]) dfs(v);
    order.push_back(u);
  }
  void dfs2(int u, int id) {
    scc[u] = id;
    if (!scc[u ^ 1]) ans[u / 2] = (u & 1) == 0;
    for (int v : G[u])
      if (!scc[v]) dfs2(v, id);
  }
  vector<bool> solve() {
    G = vector<vector<int> >(n), rG = vector<vector<int> >(n);
    scc = vector<int>(n), order = vector<int>();
    vis = vector<bool>(n), ans = vector<bool>(n / 2);
    for (auto& [u, v] : edges) {
      G[u].push_back(v);
      rG[v].push_back(u);
    }
    for (int i = 0; i < n; i++)
      if (!vis[i]) dfs(i);
    reverse((order).begin(), (order).end());
    int cnt = 1;
    for (int i : order)
      if (!scc[i]) dfs2(i, cnt++);
    for (int i = 0; i < n; i += 2)
      if (scc[i] == scc[i ^ 1]) return {};
    return ans;
  }
} ts;
int n;
struct node {
  int u;
} t[N * 4];
void build(int v = 1, int tl = 0, int tr = n) {
  t[v].u = ts.add_var();
  if (tr - tl == 1) return;
  int tm = (tl + tr) / 2;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm, tr);
}
void hit_with(int v, int u) {
  ts.either(ts.neg(t[v].u), ts.neg(u));
  int tt = ts.add_var();
  ts.implies(t[v].u, tt);
  ts.implies(u, tt);
  t[v].u = tt;
}
void push(int v) {
  hit_with(v * 2, t[v].u);
  hit_with(v * 2 + 1, t[v].u);
}
void add_tag(int l, int r, int u, int v = 1, int tl = 0, int tr = n) {
  if (l <= tl && tr <= r) {
    hit_with(v, u);
    return;
  }
  int tm = (tl + tr) / 2;
  if (l < tm) add_tag(l, r, u, v * 2, tl, tm);
  if (r > tm) add_tag(l, r, u, v * 2 + 1, tm, tr);
}
void push_down(int v = 1, int tl = 0, int tr = n) {
  if (tr - tl == 1) return;
  push(v);
  int tm = (tl + tr) / 2;
  push_down(v * 2, tl, tm);
  push_down(v * 2 + 1, tm, tr);
}
vector<int> G[N];
int p[N], sz[N], top[N], d[N];
void dfs_sz(int u, int pa = 0, int depth = 0) {
  p[u] = pa, d[u] = depth;
  if (find((G[u]).begin(), (G[u]).end(), pa) != G[u].end())
    G[u].erase(find((G[u]).begin(), (G[u]).end(), pa));
  sz[u] = 1;
  for (int i = 0; i < int(G[u].size()); i++) {
    int v = G[u][i];
    dfs_sz(v, u, depth + 1);
    sz[u] += sz[v];
    if (sz[v] > sz[G[u][0]]) swap(G[u][i], G[u][0]);
  }
}
int tin[N], tt;
void dfs_hld(int u) {
  tin[u] = tt++;
  for (int v : G[u]) {
    if (v == G[u][0])
      top[v] = top[u];
    else
      top[v] = v;
    dfs_hld(v);
  }
}
void go(int a, int b, int u) {
  if (a == b) return;
  if (top[a] == top[b]) {
    if (tin[a] > tin[b]) swap(a, b);
    add_tag(tin[a], tin[b], u);
    return;
  }
  if (d[top[a]] > d[top[b]]) swap(a, b);
  int c = p[top[b]];
  add_tag(tin[top[b]] - 1, tin[b], u);
  go(a, c, u);
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs_sz(1);
  top[1] = 1;
  dfs_hld(1);
  int m;
  cin >> m;
  ts.init(m * 2);
  build();
  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    assert(a != b && c != d);
    ts.either(ts.yes(i), ts.yes(i + m));
    go(a, b, ts.yes(i));
    go(c, d, ts.yes(i + m));
  }
  push_down();
  auto ans = ts.solve();
  if (ans.empty()) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < m; i++) {
    cout << ans[i + m] + 1 << '\n';
  }
}