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 Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.util.*;

public class Main {
	static String[][] dp;
	static String[] arr;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		arr = new String[n];
		dp = new String[n + 1][k + 1];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.next();
		}
		System.out.println(dfs(n, k));
	}
	
	static String dfs(int n, int k) {
		if (n < 0 || k < 0) {
			return null;
		}
		if (k == 0) {
			dp[n][k] = "";
			return "";
		}
		if (n == 0) {
			return null;
		}
		if (dp[n][k] != null) {
			return dp[n][k];
		}
		String s1 = dfs(n - 1, k);
		String s2 = dfs(n - 1, k - arr[n - 1].length()) + arr[n - 1];
		if (s1 == null) {
			dp[n][k] = s2;
			return s2;
		}
		if (s2 == null) {
			dp[n][k] = s1;
			return s1;
		}
		if (s1.compareTo(s2) <= 0) {
			dp[n][k] = s1;
			return s1;
		} else {
			dp[n][k] = s2;
			return s2;
		}
	}
}