#include <bits/stdc++.h>
using namespace std;
int n, dep[250002], fa[250002][20], du[250002], f[250002], fa2[250002];
vector<int> v[250002][2];
queue<int> q;
void df5(int te, int la) {
  for (int i = 0; i < v[te][0].size(); i++) {
    int j = v[te][0][i];
    if (j == la) continue;
    dep[j] = dep[te] + 1;
    fa[j][0] = te;
    df5(j, te);
  }
}
void dfs(int te, int la) {
  for (int i = 0; i < v[te][1].size(); i++) {
    int j = v[te][1][i];
    if (j == la) continue;
    du[te]++;
    fa2[j] = te;
    dfs(j, te);
  }
}
int getroot(int t) { return !f[t] ? t : f[t] = getroot(f[t]); }
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 18; ~i; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 18; ~i; i--)
    if (fa[x][i] ^ fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x][0].push_back(y);
    v[y][0].push_back(x);
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x][1].push_back(y);
    v[y][1].push_back(x);
  }
  df5(1, 1);
  fa[1][0] = 1;
  for (int i = 1; i <= 18; i++)
    for (int j = 1; j <= n; j++) fa[j][i] = fa[fa[j][i - 1]][i - 1];
  dfs(1, 1);
  for (int i = 1; i <= n; i++)
    if (!du[i]) q.push(i);
  printf("%d\n", n - 1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    int y = fa2[x];
    du[y]--;
    if (!du[y]) q.push(y);
    if (!y) return 0;
    int gf = lca(x, y);
    if (dep[getroot(x)] > dep[gf]) {
      int te = getroot(x);
      printf("%d %d %d %d\n", te, fa[te][0], x, y);
      f[te] = getroot(fa[te][0]);
    } else {
      int te = y;
      for (int i = 18; ~i; i--) {
        int tt = fa[te][i];
        if (dep[getroot(tt)] > dep[gf]) te = tt;
      }
      printf("%d %d %d %d\n", te, fa[getroot(te)][0], x, y);
      f[te] = getroot(fa[getroot(te)][0]);
    }
  }
}
