Problem: Donghyun's new social network service (SNS) contains n users numbered 1, 2, …, n. Internally, their network is a tree graph, so there are n-1 direct connections between each user. Each user can reach every other users by using some sequence of direct connections. From now on, we will denote this primary network as T_1.

To prevent a possible server breakdown, Donghyun created a backup network T_2, which also connects the same n users via a tree graph. If a system breaks down, exactly one edge e ∈ T_1 becomes unusable. In this case, Donghyun will protect the edge e by picking another edge f ∈ T_2, and add it to the existing network. This new edge should make the network be connected again. 

Donghyun wants to assign a replacement edge f ∈ T_2 for as many edges e ∈ T_1 as possible. However, since the backup network T_2 is fragile, f ∈ T_2 can be assigned as the replacement edge for at most one edge in T_1. With this restriction, Donghyun wants to protect as many edges in T_1 as possible.

Formally, let E(T) be an edge set of the tree T. We consider a bipartite graph with two parts E(T_1) and E(T_2). For e ∈ E(T_1), f ∈ E(T_2), there is an edge connecting \\{e, f\} if and only if graph T_1 - \\{e\} + \\{f\} is a tree. You should find a maximum matching in this bipartite graph.

Input

The first line contains an integer n (2 ≤ n ≤ 250 000), the number of users. 

In the next n-1 lines, two integers a_i, b_i (1 ≤ a_i, b_i ≤ n) are given. Those two numbers denote the indices of the vertices connected by the corresponding edge in T_1.

In the next n-1 lines, two integers c_i, d_i (1 ≤ c_i, d_i ≤ n) are given. Those two numbers denote the indices of the vertices connected by the corresponding edge in T_2. 

It is guaranteed that both edge sets form a tree of size n.

Output

In the first line, print the number m (0 ≤ m < n), the maximum number of edges that can be protected.

In the next m lines, print four integers a_i, b_i, c_i, d_i. Those four numbers denote that the edge (a_i, b_i) in T_1 is will be replaced with an edge (c_i, d_i) in T_2.

All printed edges should belong to their respective network, and they should link to distinct edges in their respective network. If one removes an edge (a_i, b_i) from T_1 and adds edge (c_i, d_i) from T_2, the network should remain connected. The order of printing the edges or the order of vertices in each edge does not matter.

If there are several solutions, you can print any.

Examples

Input


4
1 2
2 3
4 3
1 3
2 4
1 4


Output


3
3 2 4 2
2 1 1 3
4 3 1 4


Input


5
1 2
2 4
3 4
4 5
1 2
1 3
1 4
1 5


Output


4
2 1 1 2
3 4 1 3
4 2 1 4
5 4 1 5


Input


9
7 9
2 8
2 1
7 5
4 7
2 4
9 6
3 9
1 8
4 8
2 9
9 5
7 6
1 3
4 6
5 3


Output


8
4 2 9 2
9 7 6 7
5 7 5 9
6 9 4 6
8 2 8 4
3 9 3 5
2 1 1 8
7 4 1 3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, m, v[600005], son[600005][2], fa[600005], lazy[600005], sta[600005],
    val[600005], ea[600005], eb[600005], deg[600005];
struct Edge {
  int next, to;
} edge[600005 << 1];
int head[600005], cnt = 1;
queue<int> que;
inline void update(int x) {
  val[x] = max(v[x], max(val[son[x][0]], val[son[x][1]]));
}
inline bool isNotRoot(int x) {
  return son[fa[x]][0] == x || son[fa[x]][1] == x;
}
inline int identify(int x) { return son[fa[x]][1] == x; }
inline void change(int f, int s, int w) { fa[s] = f, son[f][w] = s; }
inline void rotate(int x) {
  int f = fa[x], g = fa[f], i = identify(x), j = identify(f);
  if (!isNotRoot(f))
    fa[x] = g;
  else
    change(g, x, j);
  change(f, son[x][i ^ 1], i), change(x, f, i ^ 1);
  update(f), update(x);
}
inline void pushr(int x) { swap(son[x][0], son[x][1]), lazy[x] ^= 1; }
inline void pushdown(int x) {
  if (lazy[x]) pushr(son[x][0]), pushr(son[x][1]), lazy[x] = 0;
}
inline void splay(int x) {
  int i = 0, y = x;
  sta[++i] = y;
  while (isNotRoot(y)) sta[++i] = y = fa[y];
  while (i) pushdown(sta[i--]);
  while (isNotRoot(x)) {
    int f = fa[x];
    if (isNotRoot(f)) {
      if (identify(x) == identify(f))
        rotate(f);
      else
        rotate(x);
    }
    rotate(x);
  }
}
inline void access(int x) {
  for (int i = 0; x; x = fa[i = x]) splay(x), son[x][1] = i, update(x);
}
inline void makeRoot(int x) { access(x), splay(x), pushr(x); }
inline int findRoot(int x) {
  access(x), splay(x);
  while (son[x][0]) pushdown(x), x = son[x][0];
  splay(x);
  return x;
}
inline void link(int x, int y) {
  makeRoot(x);
  if (x != findRoot(y)) fa[x] = y;
}
inline void cut(int x, int y) {
  makeRoot(x);
  if (findRoot(y) == x && fa[y] == x && !son[y][0])
    fa[y] = 0, son[x][1] = 0, update(x);
}
inline void add(int x, int y) {
  edge[cnt].next = head[x], edge[cnt].to = y, head[x] = cnt++;
}
inline int get(int x) {
  pushdown(x);
  if (val[son[x][0]])
    return get(son[x][0]);
  else if (v[x] == 1)
    return x;
  return get(son[x][1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", ea + i, eb + i);
    v[i + n] = 1, link(ea[i], i + n), link(eb[i], i + n);
  }
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
    ++deg[x], ++deg[y];
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] == 1) que.push(i);
  printf("%d\n", n - 1);
  while (!que.empty()) {
    int f = que.front();
    que.pop(), deg[f] = -1;
    for (int i = head[f], rt; i; i = edge[i].next) {
      if (deg[edge[i].to] == -1) continue;
      --deg[edge[i].to];
      if (deg[edge[i].to] == 1) que.push(edge[i].to);
      makeRoot(f), access(edge[i].to), splay(f), rt = get(f);
      printf("%d %d %d %d\n", ea[rt - n], eb[rt - n], f, edge[i].to);
      splay(rt), v[rt] = 0, update(rt);
    }
  }
  return 0;
}