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 = 114514, M = 8000005;
struct edge {
  int to, nxt;
} e[N << 1];
int head[N], fa[N], son[N], cnt, n, dfn[N], top[N], idx, sz[N], dep[N], idfn[N],
    m;
struct info {
  int u1, v1, u2, v2;
} A[N];
namespace Graph {
edge e[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) {
  e[++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 = e[i].nxt)
    if (!dfn[e[i].to])
      dfs(e[i].to), low[now] = min(low[now], low[e[i].to]);
    else if (vis[e[i].to])
      low[now] = min(low[now], dfn[e[i].to]);
  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 = e[i].nxt)
    if (!dep[e[i].to]) {
      dep[e[i].to] = dep[now] + 1, fa[e[i].to] = now, dfs(e[i].to);
      sz[now] += sz[e[i].to];
      if (!son[now] || sz[son[now]] < sz[e[i].to]) son[now] = e[i].to;
    }
}
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 = e[i].nxt)
    if (e[i].to != son[now] && dep[e[i].to] > dep[now])
      dfs2(top[e[i].to] = e[i].to);
}
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 add(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);
    e[++cnt] = (edge){v, head[u]}, head[u] = cnt;
    e[++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);
    add(A[i].u1, A[i].v1, i);
    add(A[i].u2, A[i].v2, i + m);
  }
  solve(1, n, 1);
  Graph::work();
  return 0;
}