Problem: Donghyun's new social network service (SNS) contains n users numbered 1, 2, …, n. Internally, their network is a tree graph, so there are n-1 direct connections between each user. Each user can reach every other users by using some sequence of direct connections. From now on, we will denote this primary network as T_1.

To prevent a possible server breakdown, Donghyun created a backup network T_2, which also connects the same n users via a tree graph. If a system breaks down, exactly one edge e ∈ T_1 becomes unusable. In this case, Donghyun will protect the edge e by picking another edge f ∈ T_2, and add it to the existing network. This new edge should make the network be connected again. 

Donghyun wants to assign a replacement edge f ∈ T_2 for as many edges e ∈ T_1 as possible. However, since the backup network T_2 is fragile, f ∈ T_2 can be assigned as the replacement edge for at most one edge in T_1. With this restriction, Donghyun wants to protect as many edges in T_1 as possible.

Formally, let E(T) be an edge set of the tree T. We consider a bipartite graph with two parts E(T_1) and E(T_2). For e ∈ E(T_1), f ∈ E(T_2), there is an edge connecting \\{e, f\} if and only if graph T_1 - \\{e\} + \\{f\} is a tree. You should find a maximum matching in this bipartite graph.

Input

The first line contains an integer n (2 ≤ n ≤ 250 000), the number of users. 

In the next n-1 lines, two integers a_i, b_i (1 ≤ a_i, b_i ≤ n) are given. Those two numbers denote the indices of the vertices connected by the corresponding edge in T_1.

In the next n-1 lines, two integers c_i, d_i (1 ≤ c_i, d_i ≤ n) are given. Those two numbers denote the indices of the vertices connected by the corresponding edge in T_2. 

It is guaranteed that both edge sets form a tree of size n.

Output

In the first line, print the number m (0 ≤ m < n), the maximum number of edges that can be protected.

In the next m lines, print four integers a_i, b_i, c_i, d_i. Those four numbers denote that the edge (a_i, b_i) in T_1 is will be replaced with an edge (c_i, d_i) in T_2.

All printed edges should belong to their respective network, and they should link to distinct edges in their respective network. If one removes an edge (a_i, b_i) from T_1 and adds edge (c_i, d_i) from T_2, the network should remain connected. The order of printing the edges or the order of vertices in each edge does not matter.

If there are several solutions, you can print any.

Examples

Input


4
1 2
2 3
4 3
1 3
2 4
1 4


Output


3
3 2 4 2
2 1 1 3
4 3 1 4


Input


5
1 2
2 4
3 4
4 5
1 2
1 3
1 4
1 5


Output


4
2 1 1 2
3 4 1 3
4 2 1 4
5 4 1 5


Input


9
7 9
2 8
2 1
7 5
4 7
2 4
9 6
3 9
1 8
4 8
2 9
9 5
7 6
1 3
4 6
5 3


Output


8
4 2 9 2
9 7 6 7
5 7 5 9
6 9 4 6
8 2 8 4
3 9 3 5
2 1 1 8
7 4 1 3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long sqr(long long x) { return x * x; }
int mysqrt(long long x) {
  int l = 0, r = 1e9 + 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (m * (long long)m <= x)
      l = m;
    else
      r = m;
  }
  return l;
}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rndll(
    chrono::high_resolution_clock::now().time_since_epoch().count());
long long AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MODR = 1e9 + 993;
long long myrand() {
  long long ZR = (XR * AR + YR * BR + CR) % MODR;
  XR = YR;
  YR = ZR;
  return ZR;
}
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
int gcdex(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int ret = gcdex(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return ret;
}
int Mod = 1e9 + 993;
int Bpow(int x, long long y) {
  int ret = 1;
  int w = x;
  while (y) {
    if (y & 1) ret = (ret * (long long)w) % Mod;
    w = (w * (long long)w) % Mod;
    y >>= 1;
  }
  return ret;
}
int Bdiv(int x) {
  int a, b;
  gcdex(x, Mod, a, b);
  if (a < 0) a += Mod;
  return a;
}
int Bdiv(int x, int y) { return (x * (long long)Bpow(y, Mod - 2)) % Mod; }
inline int ad(int x, int y) { return x + y >= Mod ? x + y - Mod : x + y; }
inline int dif(int x, int y) { return x - y < 0 ? x - y + Mod : x - y; }
inline int mul(int x, int y) { return (x * (long long)y) % Mod; }
int inv(int a) {
  int b = Mod, x = 0, y = 1;
  while (a) {
    int t = b / a;
    b -= a * t;
    x -= t * y;
    swap(a, b);
    swap(x, y);
  }
  if (x < 0) x += Mod;
  return x;
}
void setmin(int &x, int y) { x = min(x, y); }
void setmax(int &x, int y) { x = max(x, y); }
void setmin(long long &x, long long y) { x = min(x, y); }
void setmax(long long &x, long long y) { x = max(x, y); }
const long long llinf = 1e18 + 100;
const long double eps = 1e-9;
const int maxn = 5e5 + 100, maxw = 1e6 + 100, inf = 2e9 + 100, sq = 100, X = 43,
          LG = 18, B = 3000;
vector<int> ed[maxn];
int n, hei[maxn], up[LG][maxn], par[maxn], rpos[maxn], spos[maxn];
int parent[maxn];
int dget(int w) { return w == parent[w] ? w : parent[w] = dget(parent[w]); }
void duni(int x, int y) {
  x = dget(x);
  y = dget(y);
  if (x == y) return;
  if (hei[x] > hei[y]) swap(x, y);
  parent[y] = x;
}
int fen[maxn], sz;
int fget(int i) {
  int w = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1) w += fen[i];
  return w;
}
int get(int v) { return fget(rpos[v]); }
int get(int v, int u) { return fget(rpos[u]) - fget(rpos[v]); }
void inc(int i, int w) {
  for (; i < sz; i = (i | (i + 1))) fen[i] += w;
}
void upd(int i) {
  inc(rpos[i], -1);
  inc(spos[i], 1);
  duni(i, par[i]);
}
void dfs(int v, int ps) {
  par[v] = ps;
  for (int i : ed[v])
    if (i != ps) {
      hei[i] = hei[v] + 1;
      rpos[i] = sz++;
      dfs(i, v);
      spos[i] = sz++;
    }
}
void prec() {
  dfs(0, 0);
  for (int i = 0; i < n; i++) parent[i] = i;
  rpos[0] = -1;
  for (int i = 1; i < n; i++) {
    inc(rpos[i], 1);
    inc(spos[i], -1);
  }
  for (int i = 0; i < n; i++) up[0][i] = par[i];
  for (int j = 1; j < LG; j++)
    for (int i = 0; i < n; i++) up[j][i] = up[j - 1][up[j - 1][i]];
}
int getlca(int v, int u) {
  if (hei[v] < hei[u]) swap(v, u);
  for (int i = LG - 1; i >= 0; i--)
    if (hei[v] - (1 << i) >= hei[u]) v = up[i][v];
  if (v == u) return v;
  for (int i = LG - 1; i >= 0; i--)
    if (up[i][v] != up[i][u]) v = up[i][v], u = up[i][u];
  return up[0][v];
}
pair<int, int> calc(int f1, int f2) {
  int f = getlca(f1, f2);
  {
    int o = dget(f1);
    if (hei[o] > hei[f]) {
      upd(o);
      return {o, par[o]};
    }
  }
  for (int i = LG - 1; i >= 0; i--)
    if (hei[f2] - (1 << i) > hei[f] && get(f, up[i][f2])) f2 = up[i][f2];
  if (f2 != f && dget(f2) == f2) {
    upd(f2);
    return {f2, par[f2]};
  }
  return {-1, -1};
}
set<int> nig[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    ed[v].push_back(u);
    ed[u].push_back(v);
  }
  prec();
  set<pair<int, int> > degs;
  for (int i = 1; i < n; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    nig[v].insert(u);
    nig[u].insert(v);
  }
  for (int i = 0; i < n; i++) degs.insert({nig[i].size(), i});
  vector<vector<int> > ans;
  for (int iter = 1; iter < n; iter++) {
    int f1 = degs.begin()->second;
    degs.erase(degs.begin());
    int f2 = *nig[f1].begin();
    degs.erase({nig[f2].size(), f2});
    nig[f2].erase(f1);
    if (!nig[f2].empty()) degs.insert({nig[f2].size(), f2});
    auto so = calc(f1, f2);
    if (so.first != -1) ans.push_back({so.first, so.second, f1, f2});
  }
  cout << ans.size() << '\n';
  for (auto i : ans) {
    for (int j : i) cout << j + 1 << ' ';
    cout << '\n';
  }
}