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 = 120010, M = 8000005;
class edge {
 public:
  int e, nxt;
} g[N << 1];
int head[N], fa[N], son[N], cnt, n, dfn[N], top[N], idx, sz[N], dep[N], idfn[N],
    m;
class info {
 public:
  int u1, v1, u2, v2;
} A[N];
namespace Graph {
edge g[M];
int nod, dfn[M], idx, head[M], cnt, low[M], sta[M], SCC, bel[M], top;
bool vis[M];
inline void addedge(int u, int v) {
  g[++cnt] = (edge){v, head[u]}, head[u] = cnt;
}
void dfs(int now) {
  vis[now] = 1, sta[++top] = now;
  dfn[now] = low[now] = ++idx;
  for (int i = head[now]; i; i = g[i].nxt)
    if (!dfn[g[i].e])
      dfs(g[i].e), low[now] = min(low[now], low[g[i].e]);
    else if (vis[g[i].e])
      low[now] = min(low[now], dfn[g[i].e]);
  if (low[now] == dfn[now]) {
    ++SCC;
    int v;
    do {
      v = sta[top--];
      bel[v] = SCC;
      vis[v] = 0;
    } while (v != now);
  }
}
void work() {
  for (int i = 1; i <= nod; ++i)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= m; ++i)
    if (bel[i] == bel[i + m]) return void(puts("NO"));
  for (int i = m * 2 + 1; i <= nod; i += 2)
    if (bel[i] == bel[i + 1]) return void(puts("NO"));
  puts("YES");
  for (int i = 1; i <= m; ++i) puts(bel[i] < bel[i + m] ? "1" : "2");
}
}  // namespace Graph
void dfs(int now) {
  sz[now] = 1;
  for (int i = head[now]; i; i = g[i].nxt)
    if (!dep[g[i].e]) {
      dep[g[i].e] = dep[now] + 1, fa[g[i].e] = now, dfs(g[i].e);
      sz[now] += sz[g[i].e];
      if (!son[now] || sz[son[now]] < sz[g[i].e]) son[now] = g[i].e;
    }
}
void dfs2(int now) {
  idfn[dfn[now] = ++idx] = now;
  if (son[now]) top[son[now]] = top[now], dfs2(son[now]);
  for (int i = head[now]; i; i = g[i].nxt)
    if (g[i].e != son[now] && dep[g[i].e] > dep[now])
      dfs2(top[g[i].e] = g[i].e);
}
vector<int> vec[N << 2];
void add_(int l, int r, int o, const int& L, const int& R, const int& v) {
  if (L > R) return;
  if (L <= l && r <= R)
    vec[o].push_back(v);
  else {
    const int mid = (l + r) >> 1;
    if (L <= mid) add_(l, mid, o << 1, L, R, v);
    if (mid < R) add_(mid + 1, r, o << 1 | 1, L, R, v);
  }
}
inline int LCA(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) x ^= y ^= x ^= y;
    x = fa[top[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
void addedge(int x, int y, int id) {
  int t = LCA(x, y);
  bool b = 1;
deb:
  while (top[x] != top[t]) {
    add_(1, n, 1, dfn[top[x]], dfn[x], id);
    x = top[x];
    if (fa[x] == t) break;
    x = fa[x];
  }
  if (top[x] == top[t] && x != t) add_(1, n, 1, dfn[t] + 1, dfn[x], id);
  if (b) {
    x = y, b = 0;
    goto deb;
  }
}
pair<int, int> sta[N];
int tp;
void solve(int l, int r, int o) {
  int TOP = tp;
  for (int id : vec[o]) {
    pair<int, int>& nw = sta[tp + 1];
    nw.first = ++Graph::nod, nw.second = ++Graph::nod;
    int _1 = id, _0 = id > m ? id - m : id + m;
    if (tp) {
      Graph::addedge(sta[tp].first, nw.first),
          Graph::addedge(nw.second, sta[tp].second);
      Graph::addedge(sta[tp].first, _0);
      Graph::addedge(_1, sta[tp].second);
    }
    Graph::addedge(_1, nw.first), Graph::addedge(nw.second, _0);
    ++tp;
  }
  if (l < r) {
    const int mid = (l + r) >> 1;
    solve(l, mid, o << 1), solve(mid + 1, r, o << 1 | 1);
  }
  tp = TOP;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[++cnt] = (edge){v, head[u]}, head[u] = cnt;
    g[++cnt] = (edge){u, head[v]}, head[v] = cnt;
  }
  dfs(dep[1] = 1), dfs2(top[1] = 1);
  scanf("%d", &m);
  Graph::nod = m * 2;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d%d", &A[i].u1, &A[i].v1, &A[i].u2, &A[i].v2);
    addedge(A[i].u1, A[i].v1, i);
    addedge(A[i].u2, A[i].v2, i + m);
  }
  solve(1, n, 1);
  Graph::work();
  return 0;
}