#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
using namespace std;

int n, k;
string T[16];
vector<string> comb[16];
string pre[16];
int dp[1 << 16][16][6];

string now, ans;

void dfs(int bit, int p, int r) {
	if(dp[bit][p][r]) return;
	dp[bit][p][r] = 1;
	if(bit == (1 << n) - 1) {
		if(ans > now) ans = now;
		return;
	}

	string s = pre[p] + comb[p][r];
	int pos[26] = { 0 };
	for(int i = 0; i < s.size(); i++) {
		pos[s[i] - 'A'] = i;
	}

	if(now == "D") {
		//cout << endl;
	}
	for(int i = 0; i < n; i++) {
		if(bit >> i & 1) continue;
		bool ok = true;
		for(int j = 0; j < k - 1; j++) {
			if(pos[T[i][j] - 'A'] > pos[T[i][j + 1] - 'A']) {
				ok = false;
				break;
			}
		}
		if(!ok) continue;
		string rem;
		for(int j = 0; j < n; j++) {
			if(T[i].find(s[j]) == string::npos) rem += s[j];
		}
		assert(rem.size() == n - k);
		int idx = find(comb[i].begin(), comb[i].end(), rem) - comb[i].begin();
		now += 'A' + i;
		dfs(bit | (1 << i), i, idx);
		now.pop_back();
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(cin >> n >> k) {
		for(int i = 0; i < n; i++) {
			cin >> T[i];
			pre[i] = T[i];
			reverse(pre[i].begin(), pre[i].end());
		}

		for(int i = 0; i < n; i++) {
			string t;
			for(int j = 0; j < n; j++) {
				if(T[i].find('A' + j) == string::npos) t += 'A' + j;
			}
			assert(t.size() == n - k);
			comb[i].clear();
			do {
				comb[i].push_back(t);
			} while(next_permutation(t.begin(), t.end()));
		}

		memset(dp, 0, sizeof dp);
		ans = "zzzzzzzzzzzzzzzzz";
		now = "";

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < comb[i].size(); j++) {
				now += 'A' + i;
				dfs(1 << i, i, j);
				now.pop_back();
			}
		}
		cout << ans << endl;
	}
}