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: Time Limit Exceeded)

#include<bits/stdc++.h>
#define ll int
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=2100;
const ll mod=1e9+7;
const ll inf=1e9+500;

bool cmp(pair<string,ll> a,pair<string,ll> b){
    for(ll i=0;i<min(a.F.size(),b.F.size());i++){
        if(a.F[i]<b.F[i]){
            return 1;
        }
        if(a.F[i]>b.F[i]){
            return 0;
        }
    }
    if(a.S<b.S)return 1;
    return 0;
}



string s[maxn];
bitset<10020> dp[maxn];
pair<string,ll> a[maxn];
ll n;

string f(ll x,ll k){
    if(k==0){
        return "";
    }
    string ans;
    ans+=(char)('z'+1);
    if(s[x].size()<=k && dp[x+1][k-s[x].size()]){
        ans=s[x]+f(x+1,k-s[x].size());
    }
    if(dp[x+1][k]){
        ans=min(ans,f(x+1,k));
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll k;
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>s[i];
        a[i]=mp(s[i],i);
    }
    dp[n][0]=1;
    for(ll i=n-1;i>=0;i--){
        dp[i]=(dp[i+1]|(dp[i+1]<<(s[i].size())));
    }
    sort(a,a+n,cmp);
    cout<<f(0,k);
   // cout<<ans;
}