#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  int idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
template <class T>
void debug(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
const int N = 250250;
const int LG = 20;
int P[LG][N], level[N];
inline void init(int x, int par, int lev) {
  for (int i = 0; i < LG; i++) P[i][x] = -1;
  P[0][x] = par;
  level[x] = lev;
  for (int j = 1; (1 << j) < N; j++)
    if (P[j - 1][x] != -1) {
      P[j][x] = P[j - 1][P[j - 1][x]];
    }
}
inline int lca(int x, int y) {
  if (level[x] < level[y]) {
    swap(x, y);
  }
  for (int i = LG - 1; i >= 0; --i) {
    if (level[x] - (1 << i) >= level[y]) {
      x = P[i][x];
    }
  }
  for (int i = LG - 1; i >= 0; --i) {
    if (P[i][x] != P[i][y]) {
      x = P[i][x];
      y = P[i][y];
    }
  }
  return x == y ? x : P[0][x];
}
struct DSU {
  int par[N];
  DSU() {
    for (int i = 0; i < N; ++i) {
      par[i] = i;
    }
  }
  int find(int u) {
    if (u != par[u]) {
      par[u] = find(par[u]);
    }
    return par[u];
  }
  void merge(int u, int v) { par[find(u)] = find(v); }
};
vector<int> adj[2][N];
void dfs(int idx, int u, int par = -1, int lev = 0) {
  init(u, par, lev);
  for (int v : adj[idx][u]) {
    if (v != par) {
      dfs(idx, v, u, lev + 1);
    }
  }
}
DSU dsu;
pair<int, int> find(int u, int v) {
  int anc = lca(u, v);
  u = dsu.find(u), v = dsu.find(v);
  if (dsu.find(anc) != dsu.find(u)) {
    for (int i = LG - 1; i >= 0; --i) {
      if (P[i][u] != -1 and level[P[i][u]] > level[anc] and
          dsu.find(P[i][u]) == dsu.find(u)) {
        u = P[i][u];
      }
    }
    return {u, P[0][u]};
  } else {
    for (int i = LG - 1; i >= 0; --i) {
      if (P[i][v] != -1 and level[P[i][v]] > level[anc] and
          dsu.find(P[i][v]) != dsu.find(anc)) {
        v = P[i][v];
      }
    }
    return {v, P[0][v]};
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int j = 0; j < 2; ++j) {
    for (int i = 0; i < n - 1; ++i) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      adj[j][u].push_back(v);
      adj[j][v].push_back(u);
    }
  }
  vector<int> deg(n);
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    deg[i] = int(adj[1][i].size());
    if (deg[i] == 1) {
      q.push(i);
    }
  }
  cout << n - 1 << "\n";
  dfs(0, 0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    --deg[u];
    for (int v : adj[1][u]) {
      if (deg[v] > 0) {
        pair<int, int> e = find(u, v);
        dsu.merge(e.first, e.second);
        cout << e.first + 1 << " " << e.second + 1 << " " << u + 1 << " "
             << v + 1 << "\n";
        --deg[v];
        if (deg[v] == 1) {
          q.push(v);
        }
      }
    }
  }
  return 0;
}
