#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500100;
vector<int> g[2][MAXN];
struct {
  int a, b, c, d;
} ans[MAXN];
int n, x, y, tot, Fa[2][MAXN], f[MAXN];
void dfs(int i, int u, int fa) {
  Fa[i][u] = fa;
  for (int v : g[i][u])
    if (v != fa) dfs(i, v, u);
}
int find(int x) {
  if (f[x] == x) return x;
  f[x] = find(f[x]);
  return f[x];
}
void deal(int fa, int u) {
  for (int v : g[0][u])
    if (v != fa) deal(u, v);
  if (fa == -1) return;
  if (u != Fa[1][fa] && fa != Fa[1][u]) {
    ans[++tot].a = u;
    ans[tot].b = fa;
    ans[tot].c = find(u);
    ans[tot].d = Fa[1][find(u)];
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    g[0][x].push_back(y);
    g[0][y].push_back(x);
  }
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    g[1][x].push_back(y);
    g[1][y].push_back(x);
  }
  dfs(0, 1, -1);
  dfs(1, 1, -1);
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 2; i <= n; i++) {
    int u = Fa[1][i];
    if (u == Fa[0][i] || i == Fa[0][u]) f[i] = u;
  }
  deal(-1, 1);
  cout << tot << endl;
  for (int i = 1; i <= tot; i++)
    cout << ans[i].a << " " << ans[i].b << " " << ans[i].c << " " << ans[i].d
         << endl;
}
