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:
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 difierent 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. ...We say that inscription A is lexicographically less than B (assuming that lengths of A and B are the same) if A contains letter I and B contains letter X at the first position where the inscriptions differ.
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?
If the number of Xi-n-k stones is less than i then the first and only line of output should contain expression NO SUCH STONE.
입력 3 2 5 출력 XIX 입력 3 2 7 출력 NO SUCH STONE
출처:BOI 2008 7/7