时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
Special Judge, 64bit IO Format: %lld
题目描述
Dominoes are rectangular tiles made of wood, bone, or plastic. They are arranged in a line at a certain distance from each other, and when the first tile is lightly tipped over, the rest of the tiles fall in succession, creating a chain reaction.
However, now you want to use the dominoes to play a different game. Given

dominoes, each domino has two positive integers between

and

written on it. You need to arrange these dominoes in a horizontal line so that each end of a domino matches the end of the adjacent domino (except for the two ends of the line). When arranging the dominoes, you can choose either number to be on the left or right. The task is to determine if there is an arrangement where the numbers at the touching ends of adjacent dominoes are always different. If such an arrangement exists, provide a possible solution.
输入描述:
The first line of input contains an integer
, denoting the number of dominoes.
Then
lines follow. The
-th
line contains two integers
, denoting the numbers written on the
-th domino.
输出描述:
If there exists a valid way to arrange dominoes, output "Yes" in the first line (without quotes). Otherwise, output ``No'' in the first line (without quotes). You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will all be considered as positive replies.
If your answer is "Yes", you need to output two numbers
in the next
lines, where the
-th (
) line represents the numbers on the left and right sides of the
-th domino in your solution, arranged from left to right.
示例2
输入
复制
3
1 1
1000000000 1000000000
1000000000 1000000000
输出
复制
Yes
1000000000 1000000000
1 1
1000000000 1000000000