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 P = 1 << 23, Q = 1 << 20;
int inc = 0;
int las[P], e[P], nn[P];
void ins(int x, int y) {
  e[++inc] = y;
  nn[inc] = las[x];
  las[x] = inc;
}
void sss(int x, int y) { ins(x, y), ins(y ^ 1, x ^ 1); }
int ls[Q], rs[Q], tot;
vector<int> E[1 << 18], qaq[1 << 19];
void LINK(int x, int y) {
  E[x].push_back(y);
  E[y].push_back(x);
}
void MT(int &now, int l, int r) {
  now = ++tot;
  if (l == r) return;
  int mid = (l + r) >> 1;
  MT(ls[now], l, mid);
  MT(rs[now], mid + 1, r);
}
void MDF(int now, int l, int r, int x, int y, int d) {
  if (x <= l && y >= r) {
    qaq[now].push_back(d);
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid) MDF(ls[now], l, mid, x, y, d);
  if (y > mid) MDF(rs[now], mid + 1, r, x, y, d);
}
int si[Q], bs[Q], dep[Q], fa[Q], top[Q], id[Q];
void dfs1(int x) {
  int mx = 0;
  si[x] = 1;
  for (int i = 0; i < E[x].size(); i++) {
    int y = E[x][i];
    if (y == fa[x]) continue;
    fa[y] = x;
    dep[y] = dep[x] + 1;
    dfs1(y);
    si[x] += si[y];
    if (si[y] > mx) mx = si[y], bs[x] = y;
  }
}
int Time = 0;
void dfs2(int x, int T) {
  top[x] = T;
  id[x] = ++Time;
  if (bs[x]) dfs2(bs[x], T);
  for (int i = 0; i < E[x].size(); i++) {
    int y = E[x][i];
    if (y == fa[x] || y == bs[x]) continue;
    dfs2(y, y);
  }
}
int n;
int rt = 0;
void MP(int a, int b, int p) {
  while (top[a] != top[b]) {
    if (dep[top[a]] < dep[top[b]]) swap(a, b);
    MDF(rt, 1, n, id[top[a]], id[a], p);
    a = fa[top[a]];
  }
  if (dep[a] > dep[b]) swap(a, b);
  if (a != b) MDF(rt, 1, n, id[a] + 1, id[b], p);
}
int dfn[P], low[P];
int bel[P];
stack<int> st;
int scc = 0;
int inst[P];
void dfs(int x) {
  dfn[x] = low[x] = ++Time;
  inst[x] = 1;
  st.push(x);
  for (int t = las[x]; t; t = nn[t]) {
    int y = e[t];
    if (!dfn[y])
      dfs(y), low[x] = min(low[x], low[y]);
    else if (inst[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] != low[x]) return;
  int now;
  ++scc;
  do {
    now = st.top();
    st.pop();
    inst[now] = 0;
    bel[now] = scc;
  } while (now != x);
}
int tl;
int Reb(int now, int l, int r) {
  int lp = ++tl;
  if (l != r) {
    int mid = (l + r) >> 1;
    int sl = Reb(ls[now], l, mid);
    int sr = Reb(rs[now], mid + 1, r);
    sss(lp << 1 | 1, sl << 1 | 1);
    sss(lp << 1 | 1, sr << 1 | 1);
  }
  for (int i = 0; i < qaq[now].size(); i++) {
    int a = qaq[now][i];
    int ne = ++tl;
    sss(a, ne << 1);
    sss(a, lp << 1 | 1);
    sss(ne << 1 | 1, lp << 1 | 1);
    lp = ne;
  }
  return lp;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i++) scanf("%d%d", &x, &y), LINK(x, y);
  dfs1(1);
  dfs2(1, 1);
  Time = 0;
  int m;
  scanf("%d", &m);
  MT(rt, 1, n);
  for (int i = 1; i <= m; i++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    MP(a, b, i << 1);
    MP(c, d, i << 1 | 1);
  }
  tl = m;
  Reb(rt, 1, n);
  for (int i = 1; i <= m; i++) {
    if (!dfn[i << 1]) dfs(i << 1);
    if (!dfn[i << 1 | 1]) dfs(i << 1 | 1);
  }
  for (int i = 1; i <= m; i++)
    if (bel[i << 1] == bel[i << 1 | 1]) return puts("NO") & 0;
  puts("YES");
  for (int i = 1; i <= m; i++)
    printf("%d\n", bel[i << 1] < bel[i << 1 | 1] ? 1 : 2);
  return 0;
}