#P12115. [NWRRC2024] Keyboard Chaos
[NWRRC2024] Keyboard Chaos
题目描述
Haven't you ever thought that an ordinary flat keyboard is boring, and you can come up with something more interesting?
A little boy named Kevin came up with a keyboard with unusual keys. Each key initially contains a sequence of letters: . Some letters in this sequence can be equal. Each letter is one of the first lowercase English letters.
Every time key is pressed, the first letter of its sequence is typed and immediately moved to the end of the sequence. Thus, the first time key is pressed, letter is typed, and the sequence becomes . The second time key is pressed, letter is typed, and the sequence becomes $L_{i, 3}, \ldots, L_{i, |L_{i}|}, L_{i, 1}, L_{i, 2}$, and so on.
For example, suppose that key contains the sequence , , , and key contains the sequence ,. Then, if you press keys in this order, the string will be typed.
Help Kevin understand how useful his keyboard is, and find the shortest possible string consisting of the first lowercase English letters that cannot be typed with such a keyboard from the given initial state.
输入格式
The first line contains two integers and , denoting the number of keys and the size of the alphabet (; ).
The -th of the following lines consists of characters , denoting the sequence of letters key initially contains (). Every character is one of the first lowercase English letters.
输出格式
Print the shortest possible string, consisting of the first lowercase English letters, that can not be typed using Kevin's keyboard from the initial state. If there are multiple shortest strings, print any of them.
If any string can be typed, print a single string instead.
1 26
win
f
3 3
abc
bca
cab
aa
4 2
aab
bb
a
bab
NO
提示
In the first test, the only strings that can be typed with Kevin's keyboard are prefixes of . Since you can not start the string with any letter other than , any lowercase English letter except is a correct answer.
In the second test, and are other possible answers.