#include <bits/stdc++.h>
using namespace std;
int const N = 250000, B = 18;
vector<int> tr1[N + 1], tr2[N + 1];
int n, dp[N + 1], pa[N + 1][B], gr[N + 1];
int P(int v) { return gr[v] ? gr[v] = P(gr[v]) : v; }
void pl(int v = 1, int p = 0) {
  dp[v] = dp[p] + 1;
  pa[v][0] = p;
  int k = 1, z;
  while (k < B && (z = pa[v][k - 1])) pa[v][k] = pa[z][k - 1], ++k;
  for (int u : tr1[v])
    if (u != p) pl(u, v);
}
int lca(int a, int b) {
  if (dp[a] < dp[b]) swap(a, b);
  int d = dp[a] - dp[b], j = 0;
  while (d) {
    if (d & 1) a = pa[a][j];
    ++j;
    d >>= 1;
  }
  if (a == b) return a;
  for (int i = B - 1; i >= 0; --i)
    if (pa[a][i] != pa[b][i]) a = pa[a][i], b = pa[b][i];
  return pa[a][0];
}
void J(int a, int b) {
  printf("%d %d", a, b);
  gr[a] = b;
}
void kl(int a, int b) {
  a = P(a);
  int c = lca(a, b);
  if (c != a)
    J(a, pa[a][0]);
  else {
    for (int i = B - 1; i >= 0; --i)
      if (dp[pa[b][i]] > dp[c] && P(pa[b][i]) != a) b = pa[b][i];
    J(b, pa[b][0]);
  }
}
void go(int v = 1, int p = 0) {
  for (int u : tr2[v])
    if (u != p) go(u, v);
  if (p) {
    kl(v, p);
    printf(" %d %d\n", v, p);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < (int)(n); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    tr1[a].push_back(b);
    tr1[b].push_back(a);
  }
  for (int i = 1; i < (int)(n); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    tr2[a].push_back(b);
    tr2[b].push_back(a);
  }
  pl();
  printf("%d\n", n - 1);
  go();
}
