원탁에 앉은 2N명의 기사에게 두 가지 물약을 나눠 주되, 같은 조의 두 기사는 서로 다른 물약을 마시고 연속한 세 명이 같은 물약을 마시지 않도록 배정한다.
어려움8그래프그리디구현수학아직 제출이 없습니다시간 제한2초메모리 제한512 MB2N knights sit around a round table, they are numbered by King Arthur in clockwise order with integers from 1 to 2N. Knight j is a neighbor of knights j−1 and j+1, knights 1 and 2N are neighbors too. The knights represent N orders, each order is represented by exactly two knights and each knight represents exactly one order.
There are two types of magical potion today prepared by Merlin. Let's call them X and Y. Merlin wants to distribute drinks between the knights satisfying the following conditions:
Find any distribution which conforms with Merlin's requirements or determine that no such distribution exists
The first line contains a single integer N (2≤N≤5⋅105) --- the number of orders represented at the table. Each of the next N lines describes one order and contains two integers a and b (1≤a,b≤2N), denoting the numbers of knights of that order at the table. All numbers in those N lines are pairwise distinct.
If there is no solution, print a single word "impossible".
Otherwise, print a single string with 2N characters 'X' and 'Y' describing the distribution of potions. The i-th character must represent the selection for knight i.
If there is more than one possible distribution, print any of them.