SP8750 WORD - Wordplay
Description
Ivana made up a long word of N letters. Then she wrote down all K-letter-substrings of that word. For example, if the original word is BANANA and K=3, Ivana writes down the words BAN, ANA, NAN, ANA. The number of these words is, obviously, N-K+1.
Ivana sorted these words in lexicographic order (in the given example, that would be ANA, ANA, BAN, NAN).
But the sad thing happened: Ivana forgot the original word! Your task is to reconstruct it. A unique solution will exist in all of the test data.
Constraints: 3
Input Format
\[integers N, K\]
\[N-K+1 words in lexicographic order, each consisting of capital English letters\]
Output Format
\[the required word\]