Problem:
Score : 1500 points

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.

Sample Input 1

3 7
at
coder
codar

Sample Output 1

atcodar

at and codar should be chosen.

Sample Input 2

3 7
coder
codar
at

Sample Output 2

codarat

codar and at should be chosen.

Sample Input 3

4 13
kyuri
namida
zzzzzzz
aaaaaa

Sample Output 3

namidazzzzzzz

namida and zzzzzzz should be chosen.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
const int N=2005,K=10005;
char ch[N][K];
int n,k,len[N];
bitset<K> f[N];
pair<int,int> v[2][K];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%s",ch[i]+1);
		len[i]=strlen(ch[i]+1);
	}
	f[n+1][0]=1;
	for (int i=n;i;i--)f[i]=f[i+1]|(f[i+1]<<len[i]);
	int cnt=0;
	for (int i=1;i<=n;i++)
		if (f[i+1][k-len[i]])v[0][++cnt]=mp(i,1);
	for (int i=1;i<=k;i++){
		char Ans='z';
		int ncnt=0,ID=n+1;
		for (int j=1;j<=cnt;j++)Ans=min(Ans,ch[v[i-1&1][j].fi][v[i-1&1][j].se]);
		putchar(Ans);
		for (int j=1;j<=cnt;j++){
			int id=v[i-1&1][j].fi,pos=v[i-1&1][j].se;
			if (ch[id][pos]!=Ans)continue;
			if (pos<len[id])v[i&1][++ncnt]=mp(id,pos+1);
			else ID=min(ID,id);
		}
		for (int j=ID+1;j<=n;j++)
			if (k-i-len[j]>=0&&f[j+1][k-i-len[j]])v[i&1][++ncnt]=mp(j,1);
		cnt=ncnt;
	}
	return 0;
}