Consider a necklace with lettered beads that can slide along the string. Here's an example of a necklace whose beads spell the word JESSICA.

halsketting
Necklace whose lettered beads spell the name JESSICA.

We could take leftmost bead J of the necklace and slide it around to the other end to spell the word ESSICAJ. We could also take the last two beads CA and slide them to the other end to spell the word CAJESSI.

Assignment

A $$(k, n)$$-necklace is a string (str) of $$n$$ chosen from the first $$k$$ ($$1 \leq k \leq 26$$) letters of the alphabet. For example, ABBEACEEA is a $$(5, 9)$$-necklace. Note that not every possible letter needs to appear in the string.

Two necklaces $$n_1$$ and $$n_2$$ are equal if $$h_1$$ can be transformed into $$h_2$$ by sliding some beads from one end to the other end.

Your task:

Example

>>> rotation('Jessica', 1)
'essicaJ'
>>> rotation('emily', -2)
'lyemi'
>>> rotation('LOUISE', 9)
'ISELOU'

>>> rotations('Jessica')
{'CAJESSI', 'SICAJES', 'JESSICA', 'AJESSIC', 'SSICAJE', 'ESSICAJ', 'ICAJESS'}
>>> rotations('emily')
{'YEMIL', 'ILYEM', 'EMILY', 'LYEMI', 'MILYE'}
>>> rotations('LOUISE')
{'SELOUI', 'UISELO', 'ELOUIS', 'OUISEL', 'LOUISE', 'ISELOU'}

>>> normal_form('Jessica')
'AJESSIC'
>>> normal_form('emily')
'EMILY'
>>> normal_form('LOUISE')
'ELOUIS'

>>> necklaces(2, 12)
352
>>> necklaces(3, 7)
315
>>> necklaces(9, 5)
11817
>>> necklaces(21, 4)
48741
>>> necklaces(26, 3)
5876