Baltic Olympiad in Informatics: 2008 Day 1, Problem 3
Famous stones Xi-X
and I
. Each board contains exactly X
and I
are next to each other.
The top and bottom sides of the stones are not fixed, so the stones can be rotated upside-down. For instance two figures below depict exactly the same stone:
IXXIIXXX
XXXIIXXI
Two ways of looking at the same stone. This stone is of type Xi-
No two magic stones in Wonderland are the same, i.e. no two stones contain the same inscription (remember that the upside-down rotation of a stone is allowed).
If it is possible to read the inscription of some stone in two different ways (using the upside-down rotation) then the canonical representation of the stone is defined as the lexicographically less of these two ways of reading the inscription.
If a stone's inscription is symmetrical, i.e. the upside-down rotation does not change it, then its canonical representation is defined as the unique way of reading this inscription.
Example: There are exactly III
, IIX
, IXI
, IXX
, XIX
and XXX
.
Alice is a well-known expert on the Xi-
What inscription should be written at position
Constraints
Input Specification
The first and only line contains three space-separated integers
Output Specification
The only line of output should contain the
If the number of Xi-NO SUCH STONE
.
Sample Input 1
3 2 5
Sample Output 1
XIX
Sample Input 2
3 2 7
Sample Output 2
NO SUCH STONE
Comments