beecrowd | 1604

Pair-voting in The Board of Gueliz

By Renzo Gomez BR Brazil

Timelimit: 2

The neighborhood of Gueliz in Marrakech is now known to be the modern part of the city with many tourist options, restaurants and bars. Few know the formation of the district, in the sixteenth century. Originally the neighborhood, also known as "New City" was forming outside the fortress (Medina, the old city). The first new resident won an official permit from the city to build his house, and was responsible for giving new permits. When a street was opened, an inhabitant of the street (up to the first corner formed) was appointed representative of the street along with the first resident. And so it was for all city streets: the residents were representatives of the corners of the streets that were on that corner, so that each stretch of road without corners has exactly two representatives. There is a legend in Gueliz which prevents the formation of blocks (set of houses surrounded by streets). The elders say that once they formed a block in the neighborhood, and when a poor person died his spirit was trapped there forever, haunting the people who lived there. Ever since then they never formed blocks in the district.

The board of the Gueliz district is formed by the first resident and representatives of each street. These representatives form committees to analyze the various situations. In committees the counselors are grouped in pairs, and all counselors must participate in exactly one pair. Each pair has one vote and the motion is approved when they reach majority. Each pair should be formed by representatives of counselors streets that are in some corner (or the first resident and representative of his street). Clearly, when the number of counselors is odd is not possible to find a composition of committees involving all councilors. When this occurred, the first resident had one vote alone, and the others should be divided into pairs.

However, over time there have been times where it was not possible to assemble a committee, which has always been cause for suspicion among residents of Gueliz. Your task in this exercise is given N the number of street representatives (the representative number one is the first resident) decide whether it is possible to form a committee of peer counselors as described above.

Input

The input consists of several instances and ends with the end of file (EOF).

The first line in each instance contains an integer N (1 ≤ N <105). The next N - 1 lines each contain two integers. The i-th row, these N - 1 lines, contains the representatives x and y (1 ≤ x, yN) of a stretch of street without corners.

Output

For each instance, print the first line Y if it is possible to form a committee of pairs of counselors or N, otherwise. If it is possible to form a committee, print a list of pairs of counselors, one pair per line. A pair of members consisting of two integers xi and yi, separated by a space, so that xi <yi. Furthermore, the list of pairs of members should be ordered in ascending order by xi. If there is more than one way to set up a committee, print the lexicographically smallest. Note that when the representative has one vote alone, it does not belong to any pair.

Sample Input Sample Output

8

1 2

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

N
Y
1 2
3 5
4 6
7 8
9 10