#P12454. [INOI Team Selection 2021] String

[INOI Team Selection 2021] String

题目描述

Mikaeel has got nn strings named s1,,sns_{1}, \ldots, s_{n} each consists of lower-case English letters. He wants to pick a non-empty substring of each one and concatenate them together to make a final string of size kk. Help Mikaeel create the smallest lexicographical string possible.

输入格式

In the first line, you are given two integers nn and kk, the number of strings and the size of the final string, respectively.

The nn following lines contain the sequence s1,,sns_{1}, \ldots, s_{n}, the strings of Mikaeel.

输出格式

In a single line, print the smallest lexicographical string achievable.

3 5
abc
xxx
aaa
abcxa
5 6
ab
bz
zb
aa
cb
abbaab

提示

Constraints

  • n,i=1nsi4000n, \sum_{i=1}^{n}\left|s_{i}\right| \leq 4000
  • nki=1nsin \leq k \leq \sum_{i=1}^{n}\left|s_{i}\right|

Subtasks

subtask score limits
1 23 $\forall_{1 \leq i \leq n}, \vert s_{i}\vert = \vert s_{1}\vert \leq 10$,1n501 \leq n \leq 50
2 19 $\forall_{1 \leq i \leq n}, \vert s_{i}\vert = \vert s_{1} \vert \leq 20$, 1n2001 \leq n \leq 200
3 58 No extra limits