#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e6 + 1;
vector<int> G[maxn], GG[maxn];
int n;
struct node {
  int u1, v1, u2, v2;
};
vector<node> ans;
int top, u, v;
int fa[maxn];
int f1[maxn], f2[maxn];
int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
void dfs1(int x, int fa) {
  f1[x] = fa;
  for (int i = 0; i < (int)G[x].size(); i++) {
    int v = G[x][i];
    if (v == fa) continue;
    dfs1(v, x);
  }
}
void dfs2(int x, int fa) {
  f2[x] = fa;
  for (int i = 0; i < (int)GG[x].size(); i++) {
    int v = GG[x][i];
    if (v == fa) continue;
    dfs2(v, x);
  }
}
node tmp;
void getans(int x, int ff) {
  for (int i = 0; i < (int)G[x].size(); i++) {
    int v = G[x][i];
    if (v == ff) continue;
    getans(v, x);
    if (x != f2[v] && v != f2[x]) {
      tmp.u1 = x;
      tmp.v1 = v;
      tmp.u2 = f2[find(v)];
      tmp.v2 = find(v);
      ans.push_back(tmp);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    GG[u].push_back(v);
    GG[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 2; i <= n; i++)
    if (f2[i] == f1[i] || i == f1[f2[i]]) fa[i] = f2[i];
  getans(1, 0);
  printf("%d\n", ans.size());
  top = ans.size();
  for (int i = 0; i < top; i++)
    printf("%d %d %d %d\n", ans[i].u1, ans[i].v1, ans[i].u2, ans[i].v2);
  return 0;
}
