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 maxn = 9000000 + 5;
const int maxq = 5e5 + 5;
int en[maxq], nt[maxq], la[maxq], owo;
void adg(int x, int y) {
  en[++owo] = y;
  nt[owo] = la[x];
  la[x] = owo;
}
int LA[maxn], EN[maxn], NT[maxn], OWO;
void ADG(int X, int Y) {
  EN[++OWO] = Y;
  NT[OWO] = LA[X];
  LA[X] = OWO;
}
int ls[maxq], rs[maxq], segtot, rt;
int n, m, tot, IN[maxq], OUT[maxq], dfx, zerz[maxq], siz[maxq];
int dep[maxq], fa[maxq], top[maxq];
vector<int> oyo[maxq];
void ins(int x, int y) {
  ADG(x, y);
  ADG(y ^ 1, x ^ 1);
}
void dfs1(int x, int ba) {
  dep[x] = dep[ba] + 1;
  fa[x] = ba;
  siz[x] = 1;
  for (int it = la[x]; it; it = nt[it]) {
    int y = en[it];
    if (y == ba) continue;
    dfs1(y, x);
    siz[x] += siz[y];
    if (siz[zerz[x]] < siz[y]) zerz[x] = y;
  }
}
void dfs2(int x, int ace) {
  top[x] = ace;
  IN[x] = ++dfx;
  if (zerz[x]) dfs2(zerz[x], ace);
  for (int it = la[x]; it; it = nt[it]) {
    int y = en[it];
    if (y == fa[x] || y == zerz[x]) continue;
    dfs2(y, y);
  }
  OUT[x] = dfx;
}
void change(int &p, int l, int r, int x, int y, int o) {
  if (x <= l && r <= y) {
    oyo[p].push_back(o);
    return;
  }
  int mid = (l + r) >> 1;
  if (y <= mid)
    change(ls[p], l, mid, x, y, o);
  else if (x > mid)
    change(rs[p], mid + 1, r, x, y, o);
  else
    change(ls[p], l, mid, x, y, o), change(rs[p], mid + 1, r, x, y, o);
}
void modify(int x, int y, int o) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    change(rt, 1, n, IN[top[x]], IN[x], o);
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (x != y) change(rt, 1, n, IN[x] + 1, IN[y], o);
}
void maketree(int &p, int l, int r) {
  p = ++segtot;
  if (l == r) return;
  int mid = (l + r) >> 1;
  maketree(ls[p], l, mid);
  maketree(rs[p], mid + 1, r);
}
int GAO(int p, int l, int r) {
  int now = ++tot;
  if (l < r) {
    int mid = (l + r) >> 1;
    int rul = GAO(ls[p], l, mid);
    int rur = GAO(rs[p], mid + 1, r);
    ins(now * 2 + 1, rul * 2 + 1);
    ins(now * 2 + 1, rur * 2 + 1);
  }
  int net;
  for (auto o : oyo[p]) {
    net = ++tot;
    ins(o, now * 2 + 1);
    ins(net * 2 + 1, now * 2 + 1);
    ins(o, net * 2);
    now = net;
  }
  return now;
}
int dfn[maxn], low[maxn], tjdfx, sta[maxn], tp, ID[maxn], scc;
bool inst[maxn];
void tarjan(int x) {
  low[x] = dfn[x] = ++tjdfx;
  sta[++tp] = x;
  inst[x] = 1;
  for (int it = LA[x]; it; it = NT[it]) {
    int y = EN[it];
    if (!dfn[y]) {
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (inst[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] == low[x]) {
    int y;
    ++scc;
    do {
      y = sta[tp--];
      ID[y] = scc;
      inst[y] = 0;
    } while (y != x);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    adg(x, y);
    adg(y, x);
  }
  scanf("%d", &m);
  tot = m;
  maketree(rt, 1, n);
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= m; i++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    modify(a, b, i * 2);
    modify(c, d, i * 2 + 1);
  }
  GAO(rt, 1, n);
  for (int i = 2; i <= m * 2 + 1; i++) {
    if (!dfn[i]) tarjan(i);
  }
  for (int i = 1; i <= m; i++) {
    if (ID[2 * i] == ID[2 * i + 1]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  for (int i = 1; i <= m; i++) {
    if (ID[i * 2] < ID[i * 2 + 1])
      puts("1");
    else
      puts("2");
  }
  return 0;
}