#include <bits/stdc++.h>
using std::vector;
const int N = 5000010;
struct lr {
  int a, b, c, d;
  lr(int A, int B, int C, int D) : a(A), b(B), c(C), d(D) {}
};
struct Graph {
  vector<int> e[N];
  int fa[N];
  void dfs(int t) {
    for (unsigned i = 0; i < e[t].size(); ++i) {
      if (fa[t] == e[t][i]) continue;
      fa[e[t][i]] = t;
      dfs(e[t][i]);
    }
  }
} G[2];
vector<lr> ans;
int n, f[N];
int get(int u) { return u == f[u] ? u : f[u] = get(f[u]); }
void dfs(int t) {
  for (unsigned i = 0; i < G[0].e[t].size(); ++i) {
    int u = G[0].e[t][i];
    if (u == G[0].fa[t]) continue;
    dfs(u);
    if (t != G[1].fa[u] && u != G[1].fa[t]) {
      int v = get(u);
      ans.push_back(lr(u, t, v, G[1].fa[v]));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int v = 0, x, y; v < 2; ++v) {
    for (int i = 1; i < n; ++i) {
      scanf("%d%d", &x, &y);
      G[v].e[x].push_back(y);
      G[v].e[y].push_back(x);
    }
    G[v].dfs(1);
  }
  for (int i = 2; i <= n; ++i) {
    int u = G[1].fa[i];
    if (G[0].fa[i] == u || i == G[0].fa[u])
      f[i] = u;
    else
      f[i] = i;
  }
  dfs(1);
  printf("%d\n", (int)ans.size());
  for (unsigned i = 0; i < ans.size(); ++i)
    printf("%d %d %d %d\n", ans[i].a, ans[i].b, ans[i].c, ans[i].d);
  return 0;
}
