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 Ruby (2.3.3) (judge verdict: Time Limit Exceeded)

N, K = readline.split(' ').map(&:to_i)

string_list = []
N.times do
  string_list << readline.chomp
end

string_to_index_list = Hash.new {|h,k| h[k]=[]}
string_list.each_with_index do |s, i|
 string_to_index_list[s] << i
end

String_idxlist_sorted_array = []
string_to_index_list.keys.sort.each do |str|
  String_idxlist_sorted_array << [str, string_to_index_list[str]]
end

def find_first_word_len_n(strlist, index_of_last_word, pos_in_sorted_list)
  strlist_len = strlist.map(&:length).reduce(:+)
  if strlist_len==K
    puts strlist.join
    exit
  elsif strlist_len > K
    return
  end

  for pos in 0..(String_idxlist_sorted_array.length-1)
    string, idxlist = String_idxlist_sorted_array[pos]
    indexes_gt_index_of_last_word = idxlist.select{|n| n>index_of_last_word}
    if indexes_gt_index_of_last_word.size>0
      find_first_word_len_n(strlist + [string], indexes_gt_index_of_last_word[0], pos+1)
    end
  end
end

find_first_word_len_n([""], -1, 0)