#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000100;
struct Ans {
  int a, b, c, d;
  Ans(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
};
int n;
vector<Ans> ans;
vector<int> G[2][MAXN];
int fa[2][MAXN];
int pa[MAXN];
int Find(int x) { return x == pa[x] ? x : Find(pa[x]); }
void dfs(int id, int cur, int p) {
  for (int i = 0; i < G[id][cur].size(); i++) {
    int u = G[id][cur][i];
    if (u == p) continue;
    fa[id][u] = cur;
    dfs(id, u, cur);
  }
}
void dfs2(int cur, int p) {
  for (int i = 0; i < G[0][cur].size(); i++) {
    int u = G[0][cur][i];
    if (u == p) continue;
    dfs2(u, cur);
    if (cur != fa[1][u] && u != fa[1][cur]) {
      ans.push_back(Ans(u, cur, Find(u), fa[1][Find(u)]));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[0][u].push_back(v);
    G[0][v].push_back(u);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[1][u].push_back(v);
    G[1][v].push_back(u);
  }
  dfs(0, 1, 0);
  dfs(1, 1, 0);
  for (int i = 2; i <= n; i++) {
    int u = fa[1][i];
    if (u == fa[0][i] || i == fa[0][u])
      pa[i] = u;
    else
      pa[i] = i;
  }
  dfs2(1, 0);
  cout << ans.size() << endl;
  for (int 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;
}
