PivotOJ

Jungle Game

시간 제한: 1000ms메모리 제한: 1024MB출처: NCPC 2024BOJ 32558

문제

Denise is designing a rainforest themed board game. The goal of the game is for each player to form a team of two characters and complete various challenges.

There are NN different characters numbered from 11 to NN. Each character ii has two attributes pip_i and sis_i (problem solving skill and strength). The numbers pip_i and sis_i are positive integers satisfying 1pi,siN1 \leq p_i, s_i \leq N. Before the game starts, each player will pick two characters ii and jj to form a team. It is possible to pick two copies of the same character. The total problem solving skill and strength of the team will be pi+pjp_i + p_j and si+sjs_i + s_j respectively.

In the game there are also NN challenge cards numbered from 11 to NN. Each of these also has two attributes PkP_k and SkS_k. Denise has already designed the challenge cards and decided on the values of all numbers P1,P2,,PNP_1, P_2, \dots, P_N and S1,S2,,SNS_1, S_2, \dots, S_N. However, the rules of the game assume that it is not possible for a player to form a team whose problem solving skill and strength are both the same as one of the challenge cards. In other words, the situation

pi+pj=Pk and si+sj=Skp_i+p_j = P_k \text{ and } s_i+s_j = S_k

should never occur for any triple i,j,ki,j,k (note that ii can be equal to jj).

The only thing left to do is to decide the NN distinct pairs (p1,s1),(p2,s2),(pN,sN)(p_1, s_1), (p_2, s_2) \dots, (p_N, s_N) such that 1pi,siN1 \leq p_i, s_i \leq N and the situation above never happens.

입력

The first line contains the integer NN (1N20001 \leq N \leq 2000).

The following NN lines contain the values of the challenge cards Pi,SiP_i, S_i (1Pi,Si2N1 \leq P_i, S_i \leq 2 \cdot N).

출력

If there is no solution, print "NO". Otherwise, print "YES" followed by NN lines, each containing a pair of integers pi,sip_i, s_i (1pi,siN1 \leq p_i, s_i \leq N). These pairs of integers must be distinct. In other words, you may not have two indices iji \neq j with pi=pjp_i = p_j and si=sjs_i = s_j.

예제

예제 1

입력
5
5 5
5 6
6 5
6 6
8 8
출력
YES
2 2
1 1
1 2
2 1
1 3

예제 2

입력
1
2 2
출력
NO
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.