#include <bits/stdc++.h>
using namespace std;
inline int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
template <typename T>
inline bool smax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool smin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline T pw(T a, long long b) {
  T c = 1;
  while (b) {
    if (b & 1) c = (c * a);
    a = a * a;
    b >>= 1;
  }
  return c;
}
const int maxn = 500010;
vector<int> ga[maxn], gb[maxn];
int pa[maxn], push_back[maxn];
int n;
vector<pair<pair<int, int>, pair<int, int>>> res;
struct unionset {
  vector<int> p;
  unionset(int n = 1010) : p(n) {
    for (int i = 0; i < n; i++) p[i] = i;
  }
  unionset(const unionset &s) { p = s.p; }
  int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }
  void add(int x, int y) { p[root(x)] = root(y); }
};
unionset una(maxn), unb(maxn);
void dfs1(int x) {
  for (int t : ga[x])
    if (t != pa[x]) {
      pa[t] = x;
      dfs1(t);
    }
}
void dfs2(int x) {
  for (int t : gb[x])
    if (t != push_back[x]) {
      push_back[t] = x;
      if (pa[t] == x) {
        una.add(t, x);
        unb.add(t, x);
      } else if (pa[x] == t) {
        una.add(x, t);
        unb.add(t, x);
      }
      dfs2(t);
    }
}
void dfs3(int x) {
  for (int t : gb[x])
    if (t != push_back[x]) {
      if (unb.root(t) != unb.root(x)) {
        res.push_back(make_pair(pair<int, int>(una.root(t), pa[una.root(t)]),
                                pair<int, int>(t, x)));
      }
      dfs3(t);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n - 1); i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    ga[u].push_back(v);
    ga[v].push_back(u);
  }
  for (int i = 0; i < (n - 1); i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    gb[u].push_back(v);
    gb[v].push_back(u);
  }
  dfs1(0);
  dfs2(0);
  dfs3(0);
  printf("%d\n", (int)res.size());
  for (auto x : res) {
    printf("%d %d %d %d\n", x.first.first + 1, x.first.second + 1,
           x.second.first + 1, x.second.second + 1);
  }
  return 0;
}
