Codeforces Round 383 (Div. 2)
E
Arpa’s overnight party and Mehrdad’s silent entering
Codeforces
未评级
原题
← D→
翻译中…

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 $*n*$ pairs of friends sitting around a table. $*i*$-th pair consisted of a boy, sitting on the $*a*_{*i*}$-th chair, and his girlfriend, sitting on the $*b*_{*i*}$-th chair. The chairs were numbered $1$ through $2*n*$ in clockwise direction. There was exactly one person sitting on each chair.

翻译中…

image

翻译中…

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 $2*n*$ and $1$ are considered consecutive.
翻译中…

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

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ ($1  ≤  *n*  ≤  10^{5}$) — the number of pairs of guests.

翻译中…

The $*i*$-th of the next $*n*$ lines contains a pair of integers $*a*_{*i*}$ and $*b*_{*i*}$ ($1  ≤ *a*_{*i*}, *b*_{*i*} ≤  2*n*$) — the number of chair on which the boy in the $*i*$-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.

翻译中…

Output

翻译中…

If there is no solution, print -1.

翻译中…

Otherwise print $*n*$ lines, the $*i*$-th of them should contain two integers which represent the type of food for the $*i*$-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 $1$, otherwise print $2$.

翻译中…

If there are multiple solutions, print any of them.

翻译中…

样例

Input #1
3
1 4
2 5
3 6
Output #1
1 2
2 1
1 2
InputCopy OutputCopy
题目信息
题号
742E
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。