#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &t) {
  t = 0;
  char ch = getchar();
  int f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  do {
    (t *= 10) += ch - '0';
    ch = getchar();
  } while ('0' <= ch && ch <= '9');
  t *= f;
}
const int maxn = 250010;
int n, fa[maxn];
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
struct Tree {
  int tot, head[maxn], nxt[maxn * 2], to[maxn * 2];
  int in[maxn], fa[maxn][20], dep[maxn];
  void add(int x, int y) {
    tot++;
    nxt[tot] = head[x];
    head[x] = tot;
    to[tot] = y;
  }
  void dfs(int u, int p) {
    fa[u][0] = p;
    dep[u] = dep[p] + 1;
    for (int i = head[u], v; i; i = nxt[i]) {
      v = to[i];
      if (v == p) continue;
      dfs(v, u);
    }
  }
  int lca(int x, int y) {
    if (dep[x] > dep[y]) swap(x, y);
    for (int i = 19; i >= 0; i--)
      if (dep[fa[y][i]] >= dep[x]) y = fa[y][i];
    if (x == y) return x;
    for (int i = 19; i >= 0; i--)
      if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
    return fa[x][0];
  }
  void build() {
    int x, y;
    for (int i = 1; i < n; i++) {
      read(x);
      read(y);
      add(x, y);
      add(y, x);
      in[x]++;
      in[y]++;
    }
    dfs(1, 0);
    for (int j = 1; j <= 19; j++)
      for (int i = 1; i <= n; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
  }
} T1, T2;
queue<int> q;
bool vis[maxn];
int main() {
  read(n);
  T1.build();
  T2.build();
  printf("%d\n", n - 1);
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    if (T2.in[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int x = q.front(), y = -1;
    q.pop();
    vis[x] = 1;
    for (int i = T2.head[x]; i; i = T2.nxt[i]) {
      y = T2.to[i];
      if (vis[y]) {
        y = -1;
        continue;
      }
      T2.in[y]--;
      if (T2.in[y] == 1) q.push(y);
      break;
    }
    if (y == -1) continue;
    int z = T1.lca(x, y);
    int t1 = find(x), t2;
    if (T1.dep[t1] > T1.dep[z]) {
      printf("%d %d %d %d\n", T1.fa[t1][0], t1, x, y);
      fa[t1] = T1.fa[t1][0];
    } else {
      t2 = y;
      for (int i = 19; i >= 0; i--)
        if (T1.dep[T1.fa[t2][i]] > T1.dep[z] && find(T1.fa[t2][i]) != t1)
          t2 = T1.fa[t2][i];
      printf("%d %d %d %d\n", T1.fa[t2][0], t2, x, y);
      fa[t2] = t1;
    }
  }
  return 0;
}
