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 N = 1e5 + 5, LG = 16 + 4, K = 2e6 + 5;
int n, m, k, c, last[4 * N], col[K];
vector<int> adj[N], ed[K][2], topol;
int sz[N], head[N], idx[N];
vector<int> seg[4 * N];
int h[N], par[N][LG];
bool ans[K], mark[K];
void add_edge(int u, int v) {
  ed[u][0].push_back(v);
  ed[v][1].push_back(u);
}
void add_clause(int u, int v) {
  add_edge(u ^ 1, v);
  add_edge(v ^ 1, u);
}
void add(int l, int r, int x, int id = 1, int st = 0, int en = n) {
  if (r <= st || en <= l) return;
  if (l <= st && en <= r) {
    seg[id].push_back(x);
    return;
  }
  int mid = (st + en) / 2;
  add(l, r, x, id << 1, st, mid);
  add(l, r, x, id << 1 | 1, mid, en);
}
void build(int id = 1, int st = 0, int en = n) {
  int &cur = last[id] = m << 1;
  for (auto p : seg[id]) {
    add_clause(cur ^ 1, p ^ 1);
    add_clause(cur ^ 1, k << 1);
    add_clause(cur = k++ << 1, p ^ 1);
  }
  if (en - st == 1) return;
  int mid = (st + en) / 2;
  build(id << 1, st, mid);
  build(id << 1 | 1, mid, en);
}
void finalize(int prv = m << 1, int id = 1, int st = 0, int en = n) {
  int cur = k++ << 1;
  add_clause(cur, prv ^ 1);
  add_clause(cur, last[id] ^ 1);
  add_clause(prv ^ 1, last[id] ^ 1);
  if (en - st == 1) return;
  int mid = (st + en) / 2;
  finalize(cur, id << 1, st, mid);
  finalize(cur, id << 1 | 1, mid, en);
}
void lca_dfs(int u) {
  sz[u]++;
  for (int i = 0; i + 1 < LG; i++) par[u][i + 1] = par[par[u][i]][i];
  for (auto v : adj[u])
    if (v ^ par[u][0]) {
      h[v] = h[u] + 1;
      par[v][0] = u;
      lca_dfs(v);
      sz[u] += sz[v];
    }
}
void hld_dfs(int u) {
  static int cur = 0;
  idx[u] = cur++;
  int mx = -1;
  for (auto v : adj[u])
    if (v ^ par[u][0] && (!~mx || sz[mx] < sz[v])) mx = v;
  if (~mx) {
    head[mx] = head[u];
    hld_dfs(mx);
  }
  for (auto v : adj[u])
    if (v ^ par[u][0] && v ^ mx) hld_dfs(head[v] = v);
}
void dfs_t(int u) {
  mark[u] = true;
  for (auto v : ed[u][0])
    if (!mark[v]) dfs_t(v);
  topol.push_back(u);
}
void dfs_c(int u) {
  col[u] = c;
  mark[u] = true;
  for (auto v : ed[u][1])
    if (!mark[v]) dfs_c(v);
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  for (int i = LG - 1; ~i; i--)
    if (h[v] - h[u] >> i & 1) v = par[v][i];
  for (int i = LG - 1; ~i; i--)
    if (par[u][i] ^ par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return u ^ v ? par[u][0] : u;
}
void add_to_nodes(int u, int v, int id) {
  for (; head[u] ^ head[v]; u = par[head[u]][0])
    add(idx[head[u]], idx[u] + 1, id);
  add(idx[v] + 1, idx[u] + 1, id);
}
void calc(int u, int v, int id) {
  int x = lca(u, v);
  add_to_nodes(u, x, id);
  add_to_nodes(v, x, id);
}
void prepare() {
  lca_dfs(0);
  hld_dfs(0);
}
void calc_twosat() {
  for (int u = 0; u < 2 * k; u++)
    if (!mark[u]) dfs_t(u);
  reverse(topol.begin(), topol.end());
  memset(mark, false, sizeof mark);
  for (auto u : topol)
    if (!mark[u]) {
      dfs_c(u);
      c++;
    }
  for (int u = 0; u < k; u++) {
    if (col[u << 1] == col[u << 1 ^ 1]) {
      cout << "NO";
      exit(0);
    }
    ans[u] = col[u << 1] > col[u << 1 ^ 1];
  }
}
void read_input() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  prepare();
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, b--, c--, d--;
    calc(a, b, i << 1);
    calc(c, d, i << 1 ^ 1);
  }
  k = m + 1;
}
void solve() {
  build();
  finalize();
  calc_twosat();
}
void write_output() {
  cout << "YES\n";
  for (int i = 0; i < m; i++) cout << 2 - ans[i] << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}