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 = 100005;
const int M = 2000005;
int axiba = 0;
namespace Tarjin {
int dfn[M], low[M], be[M];
int stk[M], inq[M];
vector<int> e[M];
void add(int x, int y) {
  ++axiba;
  e[x].push_back(y);
}
void tarjan(int x) {
  dfn[x] = low[x] = ++*dfn;
  stk[++*stk] = x;
  inq[x] = 1;
  for (auto i : e[x])
    if (!dfn[i]) {
      tarjan(i);
      low[x] = min(low[x], low[i]);
    } else if (inq[i])
      low[x] = min(low[x], dfn[i]);
  if (low[x] == dfn[x]) {
    int y = 19260817;
    ++*be;
    for (; y != x;) {
      y = stk[(*stk)--];
      be[y] = *be;
      inq[y] = 0;
    }
  }
}
void tar(int limit) {
  for (int i = (int)(1); i <= (int)(limit); i++)
    if (!dfn[i]) tarjan(i);
}
}  // namespace Tarjin
int n, m, ndd, dep[N], fa[N][20];
int rt[N], ls[M], rs[M];
int Tag[M], nd;
pair<int, int> t[M];
vector<int> e[N];
vector<int> v[N];
void dfs(int x) {
  for (auto i : e[x])
    if (i != fa[x][0]) {
      fa[i][0] = x;
      dep[i] = dep[x] + 1;
      dfs(i);
    }
}
pair<int, int> get_info(int x, int tg) {
  if (!tg) return pair<int, int>(0, 0);
  if (tg == 1) return pair<int, int>(x * 2 - 1, x * 2);
  if (tg == 2) return pair<int, int>(x * 2, x * 2 - 1);
  int t1 = ++ndd, t2 = ++ndd;
  Tarjin::add(x * 2 - 1, t1);
  Tarjin::add(x * 2, t1);
  Tarjin::add(t2, x * 2 - 1);
  Tarjin::add(t2, x * 2);
  return pair<int, int>(t1, t2);
}
void pushup(int k) {
  pair<int, int> vl = t[ls[k]], vr = t[rs[k]];
  if (vl == pair<int, int>(0, 0))
    t[k] = vr;
  else if (vr == pair<int, int>(0, 0))
    t[k] = vl;
  else {
    int t1 = ++ndd, t2 = ++ndd;
    Tarjin::add(vl.first, vr.second);
    Tarjin::add(vr.first, vl.second);
    Tarjin::add(vl.first, t1);
    Tarjin::add(vr.first, t1);
    Tarjin::add(t2, vl.second);
    Tarjin::add(t2, vr.second);
    t[k] = pair<int, int>(t1, t2);
  }
}
void insert(int &k, int l, int r, int x) {
  if (!k) k = ++nd;
  if (l == r) {
    Tag[k] ^= (x & 1 ? 1 : 2);
    t[k] = get_info(l, Tag[k]);
    return;
  }
  int mid = (l + r) / 2;
  if (x <= 2 * mid)
    insert(ls[k], l, mid, x);
  else
    insert(rs[k], mid + 1, r, x);
}
int Merge(int x, int y, int l, int r) {
  if (!x || !y) return x + y;
  if (l == r) {
    Tag[x] ^= Tag[y];
    t[x] = get_info(l, Tag[x]);
    return x;
  }
  int mid = (l + r) / 2, k = ++nd;
  ls[k] = Merge(ls[x], ls[y], l, mid);
  rs[k] = Merge(rs[x], rs[y], mid + 1, r);
  return k;
}
void pushup(int k, int l, int r, int p) {
  if (!k || k <= p || l == r) return;
  int mid = (l + r) / 2;
  pushup(ls[k], l, mid, p);
  pushup(rs[k], mid + 1, r, p);
  pushup(k);
}
void build(int x) {
  for (auto i : e[x])
    if (i != fa[x][0]) build(i);
  int p = nd;
  for (auto i : v[x]) insert(rt[x], 1, m, i);
  for (auto i : e[x])
    if (i != fa[x][0]) rt[x] = Merge(rt[x], rt[i], 1, m);
  pushup(rt[x], 1, m, p);
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1);
  for (int i = (int)(1); i <= (int)(16); i++)
    for (int j = (int)(1); j <= (int)(n); j++)
      fa[j][i] = fa[fa[j][i - 1]][i - 1];
  scanf("%d", &m);
  ndd = 2 * m;
  for (int i = (int)(1); i <= (int)(2 * m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(i);
    v[y].push_back(i);
  }
  build(1);
  Tarjin::tar(2 * m);
  for (int i = (int)(1); i <= (int)(m); i++)
    if (Tarjin::be[i * 2 - 1] == Tarjin::be[i * 2]) return puts("NO"), 0;
  puts("YES");
  for (int i = (int)(1); i <= (int)(m); i++)
    printf("%d\n", Tarjin::be[i * 2 - 1] < Tarjin::be[i * 2] ? 1 : 2);
  cerr << axiba << endl;
}