Place each equal-number pair above or below a row so same-side joining arcs never cross, and print the lexicographically smallest side string.
Hard8GraphDFSStackGreedyNo attempts yetTime limit1sMemory limit64 MBSeokhwan sells a product called "Lightballb". One Lightballb set holds two balls that carry the same natural number. Most of the time they are ordinary balls, but when two balls with the same number are joined by a wire, they work as a light bulb.

Seunghyun heard that the product was not selling at all and bought n Lightballb sets to help Seokhwan. He owns 2n balls, and for every natural number k with 1≤k≤n exactly two balls carry the number k.
While looking for a place to store that many balls, Seunghyun found the long narrow box below and dropped the balls into it in arbitrary order.

The next day Seunghyun tried to pull the balls back out and they would not move at all. He wanted to watch the balls glow, and he had almost given up when he found out that a wire can pierce the box. Seunghyun now wants to plug the wires in so that every ball glows.
Plugging wires in carelessly risks breaking them, so Seunghyun plans the wiring first. He decided to lay both the box and the wires flat on the floor so that nothing shifts. That alone did not protect against the danger, so Seunghyun set two rules.

The three pictures above all show the box seen from above.
The numbers on the balls in Seunghyun's box are given from left to right. Decide whether the wires can be plugged in under both rules so that every ball glows, and if they can, decide for each ball whether its wire goes above the box or below it.
The first line contains a natural number n.
The second line contains a1,a2,…,a2n separated by spaces. Here ai is the number written on the i-th ball from the left in Seunghyun's box.
If no wiring satisfies both rules and lights every ball, print IMPOSSIBLE (without the quotes) on the first line.
Otherwise print a string of length 2n on the first line. Its i-th character (1≤i≤2n) is ^ if the wire plugged into the i-th ball from the left must run above the box, and v if that wire must run below the box.
If several strings satisfy both rules, print only the lexicographically smallest one. Characters compare by ASCII code, so ^ (0x5E) comes before v (0x76).