#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int v, next;
} edge[500005 << 2];
int adj[500005], adj2[500005], pos, fa[500005], fa2[500005];
int fi_fa[500005], cnt, out[500005][4];
void add(int adj[], int u, int v) {
  ++pos;
  edge[pos].v = v, edge[pos].next = adj[u];
  adj[u] = pos;
}
void dfs(int adj[], int u, int fa[]) {
  for (int p = adj[u], v; p; p = edge[p].next)
    if ((v = edge[p].v) != fa[u]) {
      fa[v] = u;
      dfs(adj, v, fa);
    }
}
int root(int u) {
  if (fi_fa[u] == u) return u;
  return fi_fa[u] = root(fi_fa[u]);
}
bool check(int x, int y) {
  if (!x || !y) return 0;
  if (fa[x] == y || fa[y] == x) return 1;
  return 0;
}
void solve(int u, int f) {
  for (int p = adj[u], v, t; p; p = edge[p].next)
    if ((v = edge[p].v) != f) {
      solve(v, u);
      if (fa2[u] != v && fa2[v] != u) {
        t = root(v);
        ++cnt;
        out[cnt][0] = u, out[cnt][1] = v, out[cnt][2] = t, out[cnt][3] = fa2[t];
      }
    }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add(adj, u, v), add(adj, v, u);
  }
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    add(adj2, u, v), add(adj2, v, u);
  }
  dfs(adj, 1, fa);
  dfs(adj2, 1, fa2);
  for (int i = 1; i <= n; ++i) fi_fa[i] = check(i, fa2[i]) ? fa2[i] : i;
  solve(1, 0);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; ++i)
    printf("%d %d %d %d\n", out[i][0], out[i][1], out[i][2], out[i][3]);
  return 0;
}
