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;
using ll = int64_t;
class CerrDummy {
} cerrDummy;
template <class T>
CerrDummy& operator<<(CerrDummy& cd, const T&) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy& cd,
                      basic_ostream<charTDummy, traitsDummy>&(
                          basic_ostream<charTDummy, traitsDummy>&)) {
  return cd;
}
using pi = pair<ll, ll>;
using vi = vector<ll>;
using ld = long double;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (ll i = ll(0); i < ll((ll)v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}
void printSpace() { printf(" "); }
void printEoln() { printf("\n"); }
void print(ll x, ll suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}
string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}
char* readCharArray() {
  static char buf[3341000];
  static ll bufUsed = 0;
  char* ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}
template <class T, class U>
void chmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void chmin(T& a, U b) {
  if (b < a) a = b;
}
template <class T>
T Sq(const T& t) {
  return t * t;
}
void Yes(bool ex = true) {
  cout << "YES" << endl;
  if (ex) exit(0);
}
void No(bool ex = true) {
  cout << "NO" << endl;
  if (ex) exit(0);
}
const ll infLL = LLONG_MAX / 3;
const ll inf = infLL;
const ll Nmax = 100010;
vi tr[Nmax];
ll par[Nmax], dep[Nmax], sub[Nmax], grp[Nmax], pos[Nmax], gsz[Nmax], gpar[Nmax],
    gdep[Nmax], gord;
ll dfs1(ll v, ll p, ll d) {
  par[v] = p;
  sub[v] = 1;
  dep[v] = d;
  for (auto to : tr[v])
    if (to != p) sub[v] += dfs1(to, v, d + 1);
  return sub[v];
}
void dfs2(ll v, ll p, ll g, ll d) {
  grp[v] = g;
  if (gsz[g] == 0) {
    gpar[g] = p;
    gdep[g] = d;
  }
  pos[v] = gsz[g]++;
  pi si(0, -1);
  for (auto to : tr[v])
    if (to != p) chmax(si, pi(sub[to], to));
  for (auto to : tr[v])
    if (to != p) {
      if (to == si.second)
        dfs2(to, v, g, d);
      else
        dfs2(to, v, gord++, d + 1);
    }
}
ll LCA(ll a, ll b) {
  if (gdep[grp[a]] > gdep[grp[b]]) swap(a, b);
  while (gdep[grp[a]] < gdep[grp[b]]) b = gpar[grp[b]];
  while (grp[a] != grp[b]) {
    a = gpar[grp[a]];
    b = gpar[grp[b]];
  }
  if (dep[a] > dep[b]) swap(a, b);
  return a;
}
struct Path {
  ll u, v, lca;
};
struct SegTree {
  vector<pi> buf;
  ll s;
  void Init(ll n) {
    s = 1;
    while (s < n) s *= 2;
    buf.assign(s * 2, pi(-inf, -1));
  }
  void Update(ll i, pi x) {
    i += s;
    buf[i] = x;
    while (i >>= 1) buf[i] = max(buf[i * 2], buf[i * 2 + 1]);
  }
  pi Get(ll b, ll e, ll l, ll r, ll i) {
    if (e <= l || r <= b) return pi(-inf, -1);
    if (b <= l && r <= e) return buf[i];
    return max(Get(b, e, l, (l + r) / 2, i * 2),
               Get(b, e, (l + r) / 2, r, i * 2 + 1));
  }
  pi Get(ll b, ll e) {
    if (e <= b) return pi(-inf, -1);
    return Get(b, e, 0, s, 1);
  }
};
struct Waf {
  vector<pi> left, right;
  vi cnt;
  vector<pair<pi, ll>> raw;
  SegTree seg;
  void Add(pi p, ll i) { raw.push_back(make_pair(p, i)); }
  void SetUp() {
    sort(raw.begin(), raw.end());
    seg.Init(raw.size());
    Clear();
  }
  ll NextVertex(pi p, ll i) {
    ll e1 = lower_bound(raw.begin(), raw.end(), make_pair(p, i)) - raw.begin();
    assert(e1 < ll(raw.size()) && raw[e1] == make_pair(p, i));
    ll e2 = lower_bound(raw.begin(), raw.end(),
                        make_pair(pi(p.second + 1, -inf), -inf)) -
            raw.begin();
    pi g = seg.Get(0, e1);
    if (p.first <= g.first) {
      ll j = g.second;
      seg.Update(j, pi(-inf, -1));
      return raw[j].second;
    } else {
      g = seg.Get(e1 + 1, e2);
      if (p.first <= g.first) {
        ll j = g.second;
        seg.Update(j, pi(-inf, -1));
        return raw[j].second;
      }
    }
    return -1;
  }
  void Clear() {
    for (ll i = ll(0); i < ll(raw.size()); i++)
      seg.Update(i, pi(raw[i].first.second, i));
  }
};
ll ord[Nmax], head;
Waf wafs[Nmax];
void Add(ll p, ll v, ll i) {
  while (p != v) {
    cerrDummy << p << " " << v << " " << i << endl;
    if (grp[p] == grp[v]) {
      wafs[grp[v]].Add(pi(pos[p] + 1, pos[v]), i);
      break;
    } else {
      wafs[grp[v]].Add(pi(0, pos[v]), i);
      v = gpar[grp[v]];
    }
  }
}
void dfs(ll v, bool rev, vi& vis, const vector<Path>& ps) {
  ll a = ps[v ^ rev].u, b = ps[v ^ rev].v, lca = ps[v ^ rev].lca;
  cerrDummy << v << endl;
  ord[v] = 0;
  for (ll _ = ll(0); _ < ll(2); _++) {
    while (lca != a) {
      ll to;
      if (grp[lca] == grp[a]) {
        to = wafs[grp[a]].NextVertex(pi(pos[lca] + 1, pos[a]), v ^ rev);
        if (to == -1) break;
      } else {
        to = wafs[grp[a]].NextVertex(pi(0, pos[a]), v ^ rev);
        if (to == -1) {
          a = gpar[grp[a]];
          continue;
        }
      }
      cerrDummy << v << " " << to << endl;
      to ^= 1 ^ rev;
      if (ord[to] == -1 && v / 2 != to / 2) {
        cerrDummy << v << " " << to << endl;
        dfs(to, rev, vis, ps);
      }
    }
    a = b;
  }
  vis.push_back(v);
  ord[v] = head++;
}
signed main() {
  ll n = read();
  for (ll i = ll(0); i < ll(n - 1); i++) {
    ll u = read() - 1, v = read() - 1;
    tr[u].push_back(v);
    tr[v].push_back(u);
  }
  dfs1(0, -1, 0);
  dfs2(0, -1, gord++, 0);
  ll m = read();
  vector<Path> ps(m * 2);
  for (ll i = ll(0); i < ll(m); i++) {
    ll a = read() - 1, b = read() - 1, c = read() - 1, d = read() - 1;
    ps[i * 2] = Path{a, b, LCA(a, b)};
    ps[i * 2 + 1] = Path{c, d, LCA(c, d)};
  }
  cerrDummy << endl;
  for (ll i = ll(0); i < ll(m * 2); i++) {
    Add(ps[i].lca, ps[i].u, i);
    Add(ps[i].lca, ps[i].v, i);
  }
  cerrDummy << endl;
  for (ll i = ll(0); i < ll(gord); i++) wafs[i].SetUp();
  memset(ord, -1, sizeof(ord));
  cerrDummy << endl;
  for (ll i = ll(0); i < ll(m * 2); i++)
    if (ord[i] == -1) {
      vi tmp;
      dfs(i, true, tmp, ps);
    }
  cerrDummy << endl;
  for (ll i = ll(0); i < ll(gord); i++) wafs[i].Clear();
  vector<pi> oi(m * 2);
  for (ll i = ll(0); i < ll(m * 2); i++) oi[i] = pi(ord[i], i);
  sort(oi.begin(), oi.end(), greater<pi>());
  vi used(m, 0), ans(m, -1);
  memset(ord, -1, sizeof(ord));
  for (ll _i = ll(0); _i < ll(m * 2); _i++) {
    ll i = oi[_i].second;
    if (ord[i] == -1) {
      vi vis;
      cerrDummy << endl;
      dfs(i, false, vis, ps);
      for (auto v : vis) {
        if (used[v / 2]) {
          No();
        }
        used[v / 2] = 1;
      }
      for (auto v : vis) {
        used[v / 2] = 0;
        if (ans[v / 2] == -1) ans[v / 2] = v % 2;
      }
    }
  }
  Yes(false);
  for (ll i = ll(0); i < ll(m); i++) print(ans[i] + 1);
}