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>
using namespace std;

string s[2005];
unordered_map<int,unordered_map<int,string> >dp;
struct Double_Ended_Queue
{
	int Q[2005],h=1,l=0;
	inline bool empty()
		{
			return h>l;
		}
	inline int front()
		{
			return Q[h];
		}
	inline int back()
		{
			return Q[l];
		}
	inline void pop_back()
		{
			--l;
		}
	inline void push_back(int x)
		{
			Q[++l]=x;
		}
}q[2005];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n,k;
	cin>>n>>k;
//	for(int i=1;i<=k;++i) for(int j=1;j<=n;++j) dp[i][j]="Z";
	for(int i=1;i<=n;++i)
	{
		cin>>s[i];
		int len=s[i].length();
		dp[len][i]=s[i];
		q[len].push_back(i);
	}
	for(int j=1;j<=n;++j)
	{
		int len=s[j].length();
		for(int i=len;i<=k;++i)
		{
			if(!q[i-len].empty()) dp[i][j]=dp[i-len][q[i-len].front()]+s[j];
			else continue;
			while(!q[i].empty()&&dp[i][j]<=dp[i][q[i].back()]) q[i].pop_back();
			q[i].push_back(j);
		}
	}
	string ans="zzzzzzzzzzzz";
	for(int i=1;i<=n;++i)
		if(dp[k][i]!="") ans=min(ans,dp[k][i]);
	cout<<ans<<endl;
	return 0;
}