#include <bits/stdc++.h>
const int kN = 250000 + 5;
const int kLog = 18;
int dsu[kN];
std::vector<int> edges[kN], e2[kN];
int n;
int depth[kN], parent[kN][kLog];
void dfs(int u, int fa) {
  parent[u][0] = fa;
  for (int i = 1; i < kLog; ++i)
    parent[u][i] =
        parent[u][i - 1] == -1 ? -1 : parent[parent[u][i - 1]][i - 1];
  for (int v : edges[u])
    if (v != fa) {
      depth[v] = depth[u] + 1;
      dfs(v, u);
    }
}
int find(int x) { return dsu[x] = dsu[x] == x ? x : find(dsu[x]); }
int get_lca(int a, int b) {
  if (depth[a] < depth[b]) std::swap(a, b);
  for (int i = kLog - 1; i >= 0; --i)
    if (depth[a] - depth[b] >> i & 1) a = parent[a][i];
  if (a == b) return a;
  for (int i = kLog - 1; i >= 0; --i)
    if (parent[a][i] != parent[b][i]) a = parent[a][i], b = parent[b][i];
  return parent[a][0];
}
void dfs2(int u, int fa) {
  for (int v : e2[u])
    if (v != fa) {
      dfs2(v, u);
      int x = find(v);
      int y = find(u);
      int lca = get_lca(u, v);
      if (depth[x] > depth[lca]) {
        printf("%d %d %d %d\n", x + 1, parent[x][0] + 1, u + 1, v + 1);
        dsu[x] = parent[x][0];
      } else {
        if (depth[y] <= depth[lca]) {
          while (true) puts("fuck");
        }
        for (int i = kLog - 1; i >= 0; --i)
          if (parent[y][i] != -1) {
            int z = find(parent[y][i]);
            if (depth[z] > depth[lca]) {
              y = parent[y][i];
            }
          }
        y = find(y);
        printf("%d %d %d %d\n", y + 1, parent[y][0] + 1, u + 1, v + 1);
        dsu[y] = parent[y][0];
      }
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  std::iota(dsu, dsu + n, 0);
  dfs(0, -1);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    e2[a].emplace_back(b);
    e2[b].emplace_back(a);
  }
  printf("%d\n", n - 1);
  dfs2(0, -1);
}
