CF741C.Arpa’s overnight party and Mehrdad’s silent entering

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Note that girls in Arpa’s land are really attractive.

Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw nn pairs of friends sitting around a table. ii -th pair consisted of a boy, sitting on the aia_{i} -th chair, and his girlfriend, sitting on the bib_{i} -th chair. The chairs were numbered 11 through 2n2n in clockwise direction. There was exactly one person sitting on each chair.

There were two types of food: Kooft and Zahre-mar. Now Mehrdad wonders, was there any way to serve food for the guests such that:

  • Each person had exactly one type of food,
  • No boy had the same type of food as his girlfriend,
  • Among any three guests sitting on consecutive chairs, there was two of them who had different type of food. Note that chairs 2n2n and 11 are considered consecutive.

Find the answer for the Mehrdad question. If it was possible, find some arrangement of food types that satisfies the conditions.

输入格式

The first line contains an integer nn ( 1<=n<=1051<=n<=10^{5} ) — the number of pairs of guests.

The ii -th of the next nn lines contains a pair of integers aia_{i} and bib_{i} ( 1<=ai,bi<=2n1<=a_{i},b_{i}<=2n ) — the number of chair on which the boy in the ii -th pair was sitting and the number of chair on which his girlfriend was sitting. It's guaranteed that there was exactly one person sitting on each chair.

输出格式

If there is no solution, print -1.

Otherwise print nn lines, the ii -th of them should contain two integers which represent the type of food for the ii -th pair. The first integer in the line is the type of food the boy had, and the second integer is the type of food the girl had. If someone had Kooft, print 11 , otherwise print 22 .

If there are multiple solutions, print any of them.

输入输出样例

  • 输入#1

    3
    1 4
    2 5
    3 6
    

    输出#1

    1 2
    2 1
    1 2
    
首页