AtCoder Regular Contest 058
F
Iroha Loves Strings
AtCoder
⌀ 3678
原题
← E→
翻译中…

Problem Statement

翻译中…

Iroha has a sequence of $N$ strings $s_1, s_2, ..., s_N$.

翻译中…

She will choose some (possibly all) strings from the sequence, then concatenate those strings retaining the relative order, to produce a long string.

翻译中…

Among all strings of length $K$ that she can produce in this way, find the lexicographically smallest one.

翻译中…

Constraints

翻译中…
  • $1 ≦ N ≦ 2000$
  • $1 ≦ K ≦ 10^4$
  • For each $i$, $1 ≦ |s_i| ≦ K$.
  • $|s_1| + |s_2| + ... + |s_N| ≦ 10^6$
  • For each $i$, $s_i$ consists of lowercase letters.
  • There exists at least one string of length $K$ that Iroha can produce.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N K
s_1
s_2
:
s_N

翻译中…

Output

翻译中…

Print the lexicographically smallest string of length $K$ that Iroha can produce.

翻译中…

样例

Input #1
3 7
at
coder
codar
Output #1
atcodar
`at` and `codar` should be chosen.
Input #2
3 7
coder
codar
at
Output #2
codarat
`codar` and `at` should be chosen.
Input #3
4 13
kyuri
namida
zzzzzzz
aaaaaa
Output #3
namidazzzzzzz
`namida` and `zzzzzzz` should be chosen.
题目信息
题号
arc058_d
时间限制
5 s
内存限制
750 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。