#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 500000 + 10;
vector<int> g[2][MAXN];
int f[MAXN], fa[2][MAXN];
void dfs1(int id, int u) {
  for (register int i = 0; i <= (int)g[id][u].size() - 1; i++) {
    int v = g[id][u][i];
    if (fa[id][u] == v) continue;
    fa[id][v] = u;
    dfs1(id, v);
  }
}
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
int cnt = 0;
struct edge {
  int x, y, u, v;
} ans[MAXN];
void dfs2(int u) {
  for (register int i = 0; i <= (int)g[0][u].size() - 1; i++) {
    int v = g[0][u][i];
    if (v == fa[0][u]) continue;
    dfs2(v);
    if (fa[1][v] != u && fa[1][u] != v)
      ans[++cnt] = (edge){u, v, find(v), fa[1][find(v)]};
  }
}
int main() {
  int k = read();
  for (register int i = 1; i <= k - 1; i++) {
    int u = read(), v = read();
    g[0][u].push_back(v);
    g[0][v].push_back(u);
  }
  for (register int i = 1; i <= k - 1; i++) {
    int u = read(), v = read();
    g[1][u].push_back(v);
    g[1][v].push_back(u);
  }
  dfs1(0, 1);
  dfs1(1, 1);
  for (register int i = 1; i <= k; i++)
    f[i] = (fa[1][i] == 0 || (fa[0][i] != fa[1][i] && fa[0][fa[1][i]] != i))
               ? i
               : fa[1][i];
  dfs2(1);
  printf("%d\n", cnt);
  for (register int i = 1; i <= cnt; i++)
    printf("%d %d %d %d\n", ans[i].x, ans[i].y, ans[i].u, ans[i].v);
  return 0;
}
