Baltic Olympiad in Informatics: 2008 Day 1, Problem 3
Famous stones Xi-- can only be found in Wonderland. Such a stone is simply a granite board with an
inscription consisting only of letters X
and I
. Each board contains exactly letters. There are not more than
positions in each board where letters 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--, but also Xi-- (and also of any type Xi-- for ).
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 stones of type Xi--. Their canonical representations written in lexicographical order are: III
, IIX
, IXI
, IXX
, XIX
and XXX
.
Alice is a well-known expert on the Xi-- stones from Wonderland. She would like to create a lexicographical index of the canonical representations of all stones of type Xi-- (for some specific values of and ).
What inscription should be written at position of the index, for a given value of ?
Constraints
Input Specification
The first and only line contains three space-separated integers , and .
Output Specification
The only line of output should contain the (in the lexicographical order) canonical representation of a Xi-- stone.
If the number of Xi-- stones is less than , then output 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