#include <bitset>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <functional>
#include <utility>
#include <string>

const int N = 2001;
const int M = 20002;

using Bitset = std::bitset<M>;
using Segment = std::pair<int, bool>;

int n, m, z[M];
bool has[M];
std::string s[N];
Bitset can[N];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        static char buf[M];
        scanf("%s", buf);
        s[i] = buf;
    }
    can[n].set(0);
    for (int i = n; i >= 1; -- i) {
        can[i - 1] = can[i] | can[i] << s[i - 1].size();
    }
    has[0] = true;
    std::string candidate;
    for (int i = 0; i < n; ++ i) {
//printf("Stage %d: \n", i);
        std::string buf = s[i] + "$" + candidate;
        memset(z, 0, sizeof(z));
        for (int i = 1, j = 0; i < (int)buf.size(); ++ i) {
            if (i < j + z[j]) {
                z[i] = std::min(z[i - j], j + z[j] - i);
            }
            while (i + z[i] < (int)buf.size() && buf[z[i]] == buf[i + z[i]]) {
                z[i] ++;
            }
            if (j + z[j] < i + z[i]) {
                j = i;
            }
        }
//puts(buf.c_str());
//for (int j = 0; j < (int)buf.size(); ++ j) { printf("%d", z[j]); } puts("");
        int l = z[0] = s[i].size();
        Segment best {-1, false};

        auto get_len = [&](const Segment& u)
        {
            return u.first + (u.second ? l : 0);
        };

        auto at = [&](const Segment& a, int pos) -> char
        {
            return pos < a.first ? candidate[pos] : s[i][pos - a.first];
        };

        std::function<int(const Segment&, const Segment&)> compare = [&](const Segment& a, const Segment& b)
        {
            if (a.first < b.first) {
                return -compare(b, a);
            }
            // a.first >= b.first
            int lcp = b.first;
            if (b.second) {
                lcp += std::min(z[l + 1 + b.first], a.first - b.first);
                if (a.second && lcp == a.first) {
                    lcp += z[a.first - b.first];
                }
            }
            if (lcp == std::min(get_len(a), get_len(b))) {
                return 0;
            }
            return at(a, lcp) - at(b, lcp);
        };

        auto update = [&](int pre_len, bool has_suf)
        {
            if (best.first == -1) {
                best = {pre_len, has_suf};
                return true;
            }
            int ret = compare(best, {pre_len, has_suf}); // a - b
            if (ret > 0) {
                best = {pre_len, has_suf};
            }
            return ret >= 0;
        };

        for (int j = m; j >= 0; -- j) {
            bool ok = false;
            if (has[j] && can[i + 1].test(m - j)) {
                ok |= update(j, false);
            }
            if (j >= l && has[j - l] && can[i + 1].test(m - j)) {
                ok |= update(j - l, true);
            }
            has[j] = ok;
        }
        candidate = candidate.substr(0, best.first);
        if (best.second) {
            candidate += s[i];
        }
        for (int j = (int)candidate.size() + 1; j <= m; ++ j) {
            has[j] = false;
        }
    }
    puts(candidate.c_str());
}


Measured memory_bytes: 6400