Network

No attempts yetTime limit1sMemory limit256 MB

Problem

The government of Byteland decided to connect the country to the Internet, so that every citizen can enter programming contests and watch videos of cute cats. It gave Internet Optimists Inc. the job of connecting all nn computers of Byteland. Each link joins two computers directly, and any two computers are connected through a sequence of links.

Byteland is not a rich country, so the company kept the cost down by building the network as a tree. There are exactly n1n-1 links between computers. Much later it turned out that this design has a serious weakness. If a single link breaks, the network falls apart and some computers can no longer talk to each other.

The network of Byteland has to survive at least one broken link. Given the tree, find the minimum number of links that have to be added so that all computers stay connected after any single link breaks, and print those links.

Input

The first line contains the number of computers nn in Byteland (n3n \ge 3). The computers are numbered from 11 to nn.

Each of the next n1n-1 lines contains two integers aa and bb (1a,bn1 \le a, b \le n, aba \ne b), a link that joins computers aa and bb directly. The given links form a tree.

Output

Print the minimum number of links kk that have to be added on the first line. On each of the next kk lines print two computer numbers aa and bb (1a,bn1 \le a, b \le n, aba \ne b) that get a new link.

Several different sets of kk links work, so only the set chosen by the following rule is accepted.

  1. Let rr be the smallest numbered computer that has at least two links, and root the tree at rr.
  2. Run a depth first search from rr. At every computer, visit the neighbours in increasing order of number. Let l1,l2,,lLl_1, l_2, \dots, l_L be the computers that have exactly one link, in the order the search first reaches them.
  3. Let h=L/2h = \lceil L/2 \rceil. For every ii from 11 to LhL-h, choose the pair (li,li+h)(l_i, l_{i+h}).
  4. If LL is odd, choose one more pair (lh,l1)(l_h, l_1).
  5. The number of chosen pairs is kk, and it equals L/2\lceil L/2 \rceil.
  6. Print the smaller number of a pair first, and print all pairs sorted in increasing order, one per line.

A pair chosen by this rule never repeats a link that already exists.