Problem: My name is James diGriz, I'm the most clever robber and treasure hunter in the whole galaxy. There are books written about my adventures and songs about my operations, though you were able to catch me up in a pretty awkward moment.

I was able to hide from cameras, outsmart all the guards and pass numerous traps, but when I finally reached the treasure box and opened it, I have accidentally started the clockwork bomb! Luckily, I have met such kind of bombs before and I know that the clockwork mechanism can be stopped by connecting contacts with wires on the control panel of the bomb in a certain manner.

I see n contacts connected by n - 1 wires. Contacts are numbered with integers from 1 to n. Bomb has a security mechanism that ensures the following condition: if there exist k ≥ 2 contacts c1, c2, ..., ck forming a circuit, i. e. there exist k distinct wires between contacts c1 and c2, c2 and c3, ..., ck and c1, then the bomb immediately explodes and my story ends here. In particular, if two contacts are connected by more than one wire they form a circuit of length 2. It is also prohibited to connect a contact with itself.

On the other hand, if I disconnect more than one wire (i. e. at some moment there will be no more than n - 2 wires in the scheme) then the other security check fails and the bomb also explodes. So, the only thing I can do is to unplug some wire and plug it into a new place ensuring the fact that no circuits appear.

I know how I should put the wires in order to stop the clockwork. But my time is running out! Help me get out of this alive: find the sequence of operations each of which consists of unplugging some wire and putting it into another place so that the bomb is defused. 

Input

The first line of the input contains n (2 ≤ n ≤ 500 000), the number of contacts.

Each of the following n - 1 lines contains two of integers xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi) denoting the contacts currently connected by the i-th wire.

The remaining n - 1 lines contain the description of the sought scheme in the same format.

It is guaranteed that the starting and the ending schemes are correct (i. e. do not contain cicuits nor wires connecting contact with itself).

Output

The first line should contain k (k ≥ 0) — the minimum number of moves of unplugging and plugging back some wire required to defuse the bomb.

In each of the following k lines output four integers ai, bi, ci, di meaning that on the i-th step it is neccesary to unplug the wire connecting the contacts ai and bi and plug it to the contacts ci and di. Of course the wire connecting contacts ai and bi should be present in the scheme.

If there is no correct sequence transforming the existing scheme into the sought one, output -1.

Examples

Input

3
1 2
2 3
1 3
3 2


Output

1
1 2 1 3


Input

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


Output

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

Note

Picture with the clarification for the sample tests:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
struct Val {
  int pos;
  Val() : pos(-1) {}
  explicit Val(int pos) : pos(pos) {}
};
struct Sum {
  int pos;
  Sum() : pos(-1) {}
  Sum(const Val &val) : pos(val.pos) {}
  Sum &operator+=(const Sum &that) {
    amax(pos, that.pos);
    return *this;
  }
  Sum operator+(const Sum &that) const { return Sum(*this) += that; }
};
struct Node {
 private:
  Node *parent, *left, *right;
  Val val;
  Sum sum;
  bool rev;

 public:
  Node()
      : parent(NULL), left(NULL), right(NULL), val(), sum(Val()), rev(false) {}

 private:
  bool is_root() const {
    return !parent || (parent->left != this && parent->right != this);
  }
  void update() {
    sum = Sum(val);
    if (left) {
      left->propagate();
      sum += left->sum;
    }
    if (right) {
      right->propagate();
      sum += right->sum;
    }
  }
  void propagate() {
    if (rev) {
      if (left) left->rev = !left->rev;
      if (right) right->rev = !right->rev;
      swap(left, right);
      rev = false;
    }
  }

 private:
  void rotateR() {
    Node *q = parent, *r = q->parent;
    if (q->left = right) right->parent = q;
    right = q;
    q->parent = this;
    if (parent = r) {
      if (r->left == q)
        r->left = this;
      else if (r->right == q)
        r->right = this;
    }
  }
  void rotateL() {
    Node *q = parent, *r = q->parent;
    if (q->right = left) left->parent = q;
    left = q;
    q->parent = this;
    if (parent = r) {
      if (r->left == q)
        r->left = this;
      else if (r->right == q)
        r->right = this;
    }
  }
  static void global_topdown(Node *a) {
    Node *r = a, *q = a->parent;
    while (q != NULL) {
      Node *p = q;
      q = p->parent;
      p->parent = r;
      r = p;
    }
    while (r != a) {
      Node *c = r->parent;
      r->parent = q;
      q = r;
      r->propagate();
      r = c;
    }
    a->propagate();
  }
  static void splay(Node *a, bool nolastupdate = false) {
    if (a->is_root()) return;
    while (1) {
      Node *p = a->parent;
      bool plr = p->right == a;
      if (p->is_root()) {
        if (!plr)
          a->rotateR(), a->right->update();
        else
          a->rotateL(), a->left->update();
        break;
      } else {
        Node *g = p->parent;
        bool glr = g->right == p;
        bool groot = g->is_root();
        if (plr == glr) {
          if (!plr)
            p->rotateR(), a->rotateR(), p->right->update();
          else
            p->rotateL(), a->rotateL(), p->left->update();
          p->update();
        } else {
          if (!plr)
            a->rotateR(), a->rotateL();
          else
            a->rotateL(), a->rotateR();
          a->left->update();
          a->right->update();
        }
        if (groot) break;
      }
    }
    if (!nolastupdate) a->update();
  }

 public:
  void setVal(const Val &val_) {
    assert(is_root());
    val = val_;
    update();
  }
  Val getVal() const {
    assert(is_root());
    return val;
  }
  Sum getSum() const {
    assert(is_root());
    return sum;
  }

 private:
  static Node *pathHead(Node *a) {
    Node *h = a;
    while (1) {
      Node *c = h->left;
      if (!c) break;
      c->propagate();
      h = c;
    }
    splay(h);
    return h;
  }
  static void splitPath(Node *a) {
    Node *r = a->right;
    if (r != NULL) {
      a->right = NULL;
      a->update();
    }
  }

 public:
  static void expose(Node *a) {
    global_topdown(a);
    Node *rp = NULL;
    for (Node *p = a; p != NULL; p = p->parent) {
      splay(p, true);
      p->right = rp;
      p->update();
      rp = p;
    }
    splay(a);
  }
  static bool exposePath(Node *a, Node *b) {
    evert(a);
    a->propagate();
    expose(b);
    if (a != b && a->parent == NULL) return false;
    splitPath(b);
    return true;
  }
  static void evert(Node *x) {
    expose(x);
    splitPath(x);
    x->rev = true;
  }
  static void connect(Node *x, Node *y) {
    evert(x);
    x->parent = y;
  }
  static void cut(Node *c) {
    expose(c);
    Node *p = c->left;
    assert(p);
    c->left = NULL;
    c->update();
    p->parent = NULL;
  }
};
int main() {
  int n;
  while (~scanf("%d", &n)) {
    vector<Node> nodes(n), edges(n - 1);
    map<pair<int, int>, int> orgEdges;
    vector<pair<int, int>> edgePairs(n - 1);
    for (int(i) = 0; (i) < (int)(n - 1); ++(i)) {
      int x;
      int y;
      scanf("%d%d", &x, &y), --x, --y;
      if (x > y) swap(x, y);
      orgEdges[make_pair((x), (y))] = i;
      edges[i].setVal(Val(i));
      Node::connect(&nodes[x], &edges[i]);
      Node::connect(&edges[i], &nodes[y]);
      edgePairs[i] = make_pair((x), (y));
    }
    vector<vector<int>> ans;
    vector<pair<int, int>> queries;
    for (int(ii) = 0; (ii) < (int)(n - 1); ++(ii)) {
      int x;
      int y;
      scanf("%d%d", &x, &y), --x, --y;
      if (x > y) swap(x, y);
      if (orgEdges.count(make_pair((x), (y)))) {
        int i = orgEdges[make_pair((x), (y))];
        Node::expose(&edges[i]);
        edges[i].setVal(Val(-1));
      } else {
        queries.emplace_back(x, y);
      }
    }
    for (auto q : queries) {
      int x, y;
      tie(x, y) = q;
      Node::exposePath(&nodes[x], &nodes[y]);
      int i = nodes[y].getSum().pos;
      assert(i != -1);
      int a, b;
      tie(a, b) = edgePairs[i];
      Node::evert(&nodes[a]);
      Node::cut(&edges[i]);
      Node::evert(&nodes[b]);
      Node::cut(&edges[i]);
      edges[i].setVal(Val(-1));
      Node::connect(&nodes[x], &edges[i]);
      Node::connect(&edges[i], &nodes[y]);
      ans.push_back({a, b, x, y});
    }
    printf("%d\n", (int)ans.size());
    for (const auto &v : ans) {
      for (int i = 0; i < 4; ++i) {
        if (i != 0) putchar(' ');
        printf("%d", v[i] + 1);
      }
      puts("");
    }
  }
  return 0;
}