Logo
(追記) (追記ここまで)

32926번 - Keyboard Chaos 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB25201982.609%

문제

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 $n$ unusual keys. Each key $i$ initially contains a sequence of letters: $L_{i, 1}, L_{i, 2}, \ldots, L_{i, |L_{i}|}$. Some letters in this sequence can be equal. Each letter is one of the first $e$ lowercase English letters.

Every time key $i$ is pressed, the first letter of its sequence is typed and immediately moved to the end of the sequence. Thus, the first time key $i$ is pressed, letter $L_{i, 1}$ is typed, and the sequence becomes $L_{i, 2}, \ldots, L_{i, |L_{i}|}, L_{i, 1}$. The second time key $i$ is pressed, letter $L_{i, 2}$ 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 1ドル$ contains the sequence 'a', 'b', 'a', and key 2ドル$ contains the sequence 'c', 'd'. Then, if you press keys 2,ドル 1, 2, 2, 1, 1, 1, 2$ in this order, the string "cadcbaad" will be typed.

Help Kevin understand how useful his keyboard is, and find the shortest possible string consisting of the first $e$ lowercase English letters that cannot be typed with such a keyboard from the given initial state.

입력

The first line contains two integers $n$ and $e,ドル denoting the number of keys and the size of the alphabet (1ドル \le n \le 100$; 2ドル \le e \le 26$).

The $i$-th of the following $n$ lines consists of characters $L_{i,1}, L_{i,2}, \ldots, L_{i, |L_i|},ドル denoting the sequence of letters key $i$ initially contains (1ドル \le |L_{i}| \le 10$). Every character is one of the first $e$ lowercase English letters.

출력

Print the shortest possible string, consisting of the first $e$ 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 "NO" instead.

제한

예제 입력 1

1 26
win

예제 출력 1

f

예제 입력 2

3 3
abc
bca
cab

예제 출력 2

aa

예제 입력 3

4 2
aab
bb
a
bab

예제 출력 3

NO

노트

In the first test, the only strings that can be typed with Kevin's keyboard are prefixes of "winwinwinwin...". Since you can not start the string with any letter other than 'w', any lowercase English letter except 'w' is a correct answer.

In the second test, "bb" and "cc" are other possible answers.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2024-2025 Northwestern Russia Regional Contest K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /