Consider all strings built from the first $N$ letters of the alphabet in which the number of a's, the number of b's, and so on are each fixed to a predetermined (though possibly different) value. List every such string in alphabetical order and number the entries starting from $0$. Given an index $K$, output the $K$-th string in this list.
For example, take the strings over $N = 2$ letters (a and b) that use exactly $2$ a's and $3$ b's. Sorted alphabetically they are:
| Index | String | Index | String |
|---|---|---|---|
| 0 | aabbb | 5 | babab |
| 1 | ababb | 6 | babba |
| 2 | abbab | 7 | bbaab |
| 3 | abbba | 8 | bbaba |
| 4 | baabb | 9 | bbbaa |
If $K = 5$, the answer is babab.
The input consists of several datasets. Each dataset spans two lines.
The first line holds two integers $N$ and $K$ ($1 \le N \le 20$, $0 \le K < m$), where $N$ is the number of alphabet letters used, $K$ is the index of the wanted list entry, and $m$ is the total number of strings in the list. The value $m$ is not given explicitly in the input.
$m$ may be extremely large — far too large to build the whole list — but the input is chosen so that both $m$ and $K$ fit in a signed 32-bit integer.
The second line holds $N$ non-negative integers: the required number of a's, of b's, and so on. Their sum is at least $1$ and at most $50$.
The input ends with a line containing two zeros.
For each dataset, print the answer string on its own line. Do not print any extra whitespace, and do not print blank lines between answers.