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: Runtime Error)

#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=2011;
#define pii pair<int,int>
#define x first
#define y second
int n,K,len[N];
bitset<N*50> ok[N];
string s[N],ans;
pii f[2][N*5];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>K;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		len[i]=s[i].size();
	}
	ok[n+1][0]=1;
	for(int i=n;i>0;i--){
		ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
//		cout<<i<<' ';
//		for(int j=0;j<=K;j++){
//			ok[i][j]|=ok[i+1][j];
//			if(j+len[i]<=K)ok[i][j+len[i]]|=ok[i+1][j];
//			printf("%d ",ok[i][j]);
//		}
//		cout<<endl;
	}
	int qcnt=0,tcnt=0;
	for(int i=1;i<=n;i++)
	  if(ok[i+1][K-len[i]])
	    f[1][++qcnt]=pii(i,0);
	for(int t=1;t<=K;t++)
	{
		int i=t&1;
//		cout<<' '<<i<<endl;
		qcnt=min(qcnt,K);
//		cout<<qcnt<<"  ";
		char ch='z';
		for(int j=1;j<=qcnt;j++)
		  ch=min(ch,s[f[i][j].x][f[i][j].y]);//cout<<f[i][j].x<<' '<<f[i][j].y<<"  ";
//		cout<<endl;
		ans.push_back(ch);
		int head=n+1;
		for(int j=1;j<=qcnt;j++)
		{
			if(s[f[i][j].x][f[i][j].y]!=ch) continue;
			if(f[i][j].y==len[f[i][j].x]-1)
			  head=min(head,f[i][j].x);
			else
			  f[i^1][++tcnt]=pii(f[i][j].x,f[i][j].y+1);
		}
//		cout<<head<<endl;
		for(int j=head+1;j<=n;j++)
		  if(K-t-len[j]>=0&&ok[j+1][K-t-len[j]])
		    f[i^1][++tcnt]=pii(j,0);
		qcnt=tcnt; tcnt=0;
	}
	cout<<ans<<endl;
	return 0;
}