Problem: My name is James diGriz, I'm the most clever robber and treasure hunter in the whole galaxy. There are books written about my adventures and songs about my operations, though you were able to catch me up in a pretty awkward moment.

I was able to hide from cameras, outsmart all the guards and pass numerous traps, but when I finally reached the treasure box and opened it, I have accidentally started the clockwork bomb! Luckily, I have met such kind of bombs before and I know that the clockwork mechanism can be stopped by connecting contacts with wires on the control panel of the bomb in a certain manner.

I see n contacts connected by n - 1 wires. Contacts are numbered with integers from 1 to n. Bomb has a security mechanism that ensures the following condition: if there exist k ≥ 2 contacts c1, c2, ..., ck forming a circuit, i. e. there exist k distinct wires between contacts c1 and c2, c2 and c3, ..., ck and c1, then the bomb immediately explodes and my story ends here. In particular, if two contacts are connected by more than one wire they form a circuit of length 2. It is also prohibited to connect a contact with itself.

On the other hand, if I disconnect more than one wire (i. e. at some moment there will be no more than n - 2 wires in the scheme) then the other security check fails and the bomb also explodes. So, the only thing I can do is to unplug some wire and plug it into a new place ensuring the fact that no circuits appear.

I know how I should put the wires in order to stop the clockwork. But my time is running out! Help me get out of this alive: find the sequence of operations each of which consists of unplugging some wire and putting it into another place so that the bomb is defused. 

Input

The first line of the input contains n (2 ≤ n ≤ 500 000), the number of contacts.

Each of the following n - 1 lines contains two of integers xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi) denoting the contacts currently connected by the i-th wire.

The remaining n - 1 lines contain the description of the sought scheme in the same format.

It is guaranteed that the starting and the ending schemes are correct (i. e. do not contain cicuits nor wires connecting contact with itself).

Output

The first line should contain k (k ≥ 0) — the minimum number of moves of unplugging and plugging back some wire required to defuse the bomb.

In each of the following k lines output four integers ai, bi, ci, di meaning that on the i-th step it is neccesary to unplug the wire connecting the contacts ai and bi and plug it to the contacts ci and di. Of course the wire connecting contacts ai and bi should be present in the scheme.

If there is no correct sequence transforming the existing scheme into the sought one, output -1.

Examples

Input

3
1 2
2 3
1 3
3 2


Output

1
1 2 1 3


Input

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


Output

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

Note

Picture with the clarification for the sample tests:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;
constexpr long long mod = 1000000007;
const long long INF = mod * mod;
const double eps = 1e-12;
const double pi = acosl(-1.0);
long long mod_pow(long long x, long long n, long long m = mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
struct modint {
  long long n;
  modint() : n(0) { ; }
  modint(long long m) : n(m) {
    if (n >= mod)
      n %= mod;
    else if (n < 0)
      n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) {
  a.n += b.n;
  if (a.n >= mod) a.n -= mod;
  return a;
}
modint operator-=(modint& a, modint b) {
  a.n -= b.n;
  if (a.n < 0) a.n += mod;
  return a;
}
modint operator*=(modint& a, modint b) {
  a.n = ((long long)a.n * b.n) % mod;
  return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, long long n) {
  if (n == 0) return modint(1);
  modint res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
long long inv(long long a, long long p) {
  return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 10;
modint fact[max_n], factinv[max_n];
void init_f() {
  fact[0] = modint(1);
  for (int i = 0; i < max_n - 1; i++) {
    fact[i + 1] = fact[i] * modint(i + 1);
  }
  factinv[max_n - 1] = modint(1) / fact[max_n - 1];
  for (int i = max_n - 2; i >= 0; i--) {
    factinv[i] = factinv[i + 1] * modint(i + 1);
  }
}
modint comb(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[b] * factinv[a - b];
}
long long gcd(long long a, long long b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b) {
    long long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
struct uf {
 private:
  vector<int> par, ran;

 public:
  uf(int n) {
    par.resize(n, 0);
    ran.resize(n, 0);
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (ran[x] < ran[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (ran[x] == ran[y]) ran[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
};
void solve() {
  int n;
  cin >> n;
  vector<set<pair<int, int>>> st1(n), st2(n);
  vector<pair<pair<int, int>, pair<int, int>>> ans;
  uf u(n);
  queue<int> que;
  auto upd = [&](int a1, int b1, int a2, int b2) {
    if (a1 != a2 || b1 != b2) {
      ans.push_back({{a1, b1}, {a2, b2}});
    }
    int p1 = u.find(a2), p2 = u.find(b2);
    u.unite(p1, p2);
    int p = u.find(p1);
    int x = p1 ^ p2 ^ p;
    if (st1[p].size() < st1[x].size()) swap(st1[x], st1[p]);
    if (st2[p].size() < st2[x].size()) swap(st2[x], st2[p]);
    for (pair<int, int> id : st1[x]) st1[p].insert(id);
    for (pair<int, int> id : st2[x]) st2[p].insert(id);
    int q1 = u.find(a1), q2 = u.find(b1);
    st1[q1].erase({a1, b1});
    st1[q2].erase({b1, a1});
    st2[p].erase({a2, b2});
    st2[p].erase({b2, a2});
    que.push(q1);
    que.push(q2);
    que.push(p);
  };
  vector<pair<int, int>> e1, e2;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    e1.push_back({a, b});
    st1[a].insert({a, b});
    st1[b].insert({b, a});
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    e2.push_back({a, b});
    st2[a].insert({a, b});
    st2[b].insert({a, b});
  }
  sort((e1).begin(), (e1).end());
  for (pair<int, int> p : e2) {
    int id = lower_bound((e1).begin(), (e1).end(), p) - e1.begin();
    if (id < e1.size() && e1[id] == p) {
      upd(p.first, p.second, p.first, p.second);
    }
  }
  for (int i = 0; i < n; i++) {
    que.push(i);
  }
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    if (v != u.find(v)) continue;
    if (st1[v].size() != 1) continue;
    pair<int, int> p1 = *st1[v].begin();
    pair<int, int> p2 = *st2[v].begin();
    upd(p1.first, p1.second, p2.first, p2.second);
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    int x1 = ans[i].first.first;
    int y1 = ans[i].first.second;
    int x2 = ans[i].second.first;
    int y2 = ans[i].second.second;
    x1++;
    y1++;
    x2++;
    y2++;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}