#include <bits/stdc++.h>
using namespace std;
int IN() {
  int f = 1, x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = 0;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 3) + (x << 1) + ch - '0';
  return f ? x : -x;
}
struct opt {
  int u, v, U, V;
  void print() { printf("%d %d %d %d\n", u, v, U, V); }
} E[500500];
int head[2][500500], cnt[2], Fa[2][500500], fa[500500], n, Ans;
struct data {
  int to, next;
} edge[2][500500 << 1];
void AddEdge(int id, int u, int v) {
  edge[id][++cnt[id]] = (data){v, head[id][u]};
  head[id][u] = cnt[id];
  edge[id][++cnt[id]] = (data){u, head[id][v]};
  head[id][v] = cnt[id];
}
int find(int k) { return fa[k] ^ k ? fa[k] = find(fa[k]) : k; }
void Dfs(int id, int u, int fa) {
  Fa[id][u] = fa;
  for (int i = head[id][u]; i; i = edge[id][i].next)
    if (edge[id][i].to ^ fa) Dfs(id, edge[id][i].to, u);
}
bool Link(int id, int u, int v) {
  return u && v && (Fa[id][u] == v || Fa[id][v] == u);
}
void Dfs(int u, int fa) {
  for (int i = head[0][u]; i; i = edge[0][i].next) {
    int v = edge[0][i].to;
    if (v == fa) continue;
    Dfs(v, u);
    if (!Link(1, u, v)) {
      int p = find(v);
      E[++Ans] = (opt){u, v, p, Fa[1][p]};
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) AddEdge(0, IN(), IN());
  Dfs(0, 1, 0);
  for (int i = 1; i <= n - 1; i++) AddEdge(1, IN(), IN());
  Dfs(1, 1, 0);
  for (int i = 1; i <= n; i++) fa[i] = Link(0, i, Fa[1][i]) ? Fa[1][i] : i;
  Dfs(1, 0);
  printf("%d\n", Ans);
  for (int i = 1; i <= Ans; i++) E[i].print();
}
