Dominoes!
时间限制: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 n dominoes, each domino has two positive integers between 1 and 10^9 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 n (1\leq n\leq 2\times 10^5), denoting the number of dominoes.

Then n lines follow. The i-th (1\leq i\leq n) line contains two integers x_i,y_i (1\leq x_i,y_i\leq 10^9), denoting the numbers written on the i-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 x_i, y_i in the next n lines, where the i-th (1 \leq i \leq n) line represents the numbers on the left and right sides of the i-th domino in your solution, arranged from left to right.
示例1

输入

复制
3
1 2
2 3
3 1

输出

复制
Yes
1 2
3 2
3 1
示例2

输入

复制
3
1 1
1000000000 1000000000
1000000000 1000000000

输出

复制
Yes
1000000000 1000000000
1 1
1000000000 1000000000
示例3

输入

复制
2
2 2
2 2

输出

复制
No