#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <bitset>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

bool contain(const std::string& s, const std::string& t) {
    auto it = t.begin();
    for (char c : s) {
        if (it != t.end() && c == *it) ++it;
    }
    return it == t.end();
}

void solve() {
    int n, k;
    std::cin >> n >> k;

    std::vector<std::pair<std::string, std::string>> ss;
    for (int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;

        std::string t;
        for (char c = 'A'; c < 'A' + n; ++c) {
            if (!std::count(s.begin(), s.end(), c)) {
                t.push_back(c);
            }
        }

        do {
            ss.emplace_back(s, t);
        } while (std::next_permutation(t.begin(), t.end()));
    }

    int d = (int)ss.size() / n;

    std::vector<std::vector<int>> to(n * d);
    for (int u = 0; u < n * d; ++u) {
        auto pu = ss[u];

        for (int v = 0; v < n * d; ++v) {
            auto pv = ss[v];

            // uの後に得られる文字列
            auto s = std::string(pu.first.rbegin(), pu.first.rend()) +
                     pu.second;

            if (contain(s, pv.first) &&
                contain(s, pv.second)) {
                to[u].push_back(v);
            }
        }
    }

    auto dp = vec(1 << n, vec(n * d, std::string(1, '$')));
    for (int v = 0; v < n * d; ++v) {
        char c = 'A' + v / d;
        dp.back()[v] = std::string(1, c);
    }

    std::function<std::string(int, int)> dfs =
        [&](int b, int v) -> std::string {
        auto& ret = dp[b][v];
        if (ret != "$") return ret;

        ret = "";
        for (auto u : to[v]) {
            int j = u / d;
            if ((b >> j) & 1) continue;

            auto res = dfs(b | (1 << j), u);
            if (res.empty()) continue;

            if (ret.empty() || res < ret) ret = res;
        }

        if (ret.empty()) return ret;

        char c = 'A' + v / d;
        ret = c + ret;
        return ret;
    };

    std::string ans(n, 'Z');
    for (int v = 0; v < n * d; ++v) {
        int i = v / d;
        auto res = dfs(1 << i, v);

        if (res.empty()) continue;
        ans = std::min(ans, res);
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}

