Baltic OI '08 P3 - Magical Stones

View as PDF

Submit solution


Points: 20 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type
Baltic Olympiad in Informatics: 2008 Day 1, Problem 3

Famous stones Xi-n-k 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 n letters. There are not more than k 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-8-3, but also Xi-8-4 (and also of any type Xi-8-k for k \ge 3).

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 6 stones of type Xi-3-2. Their canonical representations written in lexicographical order are: III, IIX, IXI, IXX, XIX and XXX.

Alice is a well-known expert on the Xi-n-k stones from Wonderland. She would like to create a lexicographical index of the canonical representations of all stones of type Xi-n-k (for some specific values of n and k).

What inscription should be written at position i of the index, for a given value of i?

Constraints

0 \le k < n \le 60

0 < i < 10^{18}

Input Specification

The first and only line contains three space-separated integers n, k and i.

Output Specification

The only line of output should contain the i^\text{th} (in the lexicographical order) canonical representation of a Xi-n-k stone.

If the number of Xi-n-k stones is less than i, 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

There are no comments at the moment.