Rotating Drum

A rock ’n’ roll band has k musicians, any of them can play any of n instruments, and they can be located in any order on the stage. This band has decided to make a drawing on the bass drum in order to characterize the way they perform on stage. The idea is to divide the surface of the bass drum into m equal sections (like a large pizza) and then assign one of k colors to each of the sections in a way that any possible sequence on n colors is found exactly once clockwise on the drum. Nick De Bruijn — a musician in the band — is a mathematician and he knows that every possible sequence of n colors must be present on the bass drum. He knows that for k ≥ 2 the value of m must beequaltokn andfork=1thevalueofmmustbeequalton. As an example, consider the following bass drum drawing sat- isfying the abovementioned constraints for k = 2 and n = 3. In this case, each one of the 8 sequences appears exactly once clockwise in the drawing. Namely, the sequences AAA, AAB, ABA, BAB, ABB, BBB, BBA, BAA. Your task is to help the band to find the sequence of colors that should be drawn on the bass drum for given k and n. Input The input consists of several test cases. Each test case is described by a line containing two blank-separated integers k and n: the number of colors (1 ≤ k ≤ 26) and the length of the subsequences (1≤n≤10). Youmayassumethat1≤m≤105. Output For each test case print a single line with the solution sequence. The k colors shall be represented by the first k uppercase letters of the English alphabet. If there is more than one solution, you must print the first sequence in lexicographical order. Sample Input 42 23 15 Sample Output AABACADBBCBDCCDD AAABABBB AAAAA