#include <bits/stdc++.h>
using namespace std;
const int maxn = 500200;
int p[maxn], fa[2][maxn];
vector<int> g[2][maxn];
vector<int> ans[4];
int n, num;
int fi(int x) { return p[x] == x ? p[x] : p[x] = fi(p[x]); }
bool check(int u, int x, int y) {
  if (fa[u][x] == y || fa[u][y] == x) return true;
  return false;
}
void dfs(int u, int x, int pra) {
  fa[u][x] = pra;
  for (auto &i : g[u][x])
    if (i != pra) dfs(u, i, x);
}
void solve(int u, int pra) {
  for (auto &v : g[0][u])
    if (v != pra) {
      solve(v, u);
      if (!check(1, u, v)) {
        int w = fi(v);
        ans[0].push_back(u);
        ans[1].push_back(v);
        ans[2].push_back(w);
        ans[3].push_back(fa[1][w]);
        num++;
      }
    }
  return;
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[0][u].push_back(v);
    g[0][v].push_back(u);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[1][u].push_back(v);
    g[1][v].push_back(u);
  }
  for (int i = 1; i <= n; i++) p[i] = i;
  dfs(0, 1, 0);
  dfs(1, 1, 0);
  for (int i = 2; i <= n; i++)
    if (check(0, i, fa[1][i])) p[i] = fa[1][i];
  solve(1, 0);
  printf("%d\n", num);
  for (int i = 0; i < num; i++)
    printf("%d %d %d %d\n", ans[0][i], ans[1][i], ans[2][i], ans[3][i]);
}
