#include <bits/stdc++.h>
using namespace std;
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
string tostring(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long ans = pw(a, b / 2);
  if (b & 1) return (((ans * ans) % 1000000007 * a) % 1000000007);
  return (ans * ans) % 1000000007;
}
long long const NMAX = 2e5 + 20;
string str[2600];
int main_cnt[30], cnt[30];
int ind_cnt[5100][5100];
int main() {
  int k, n;
  scanf("%d", &k);
  scanf("%d", &n);
  bool two = false;
  for (int i = 1; i <= k; i++) cin >> str[i];
  for (auto ch : str[1]) {
    main_cnt[ch - 'a' + 1]++;
    if (main_cnt[ch - 'a' + 1] > 1) two = true;
  }
  bool ans = true;
  for (int i = 2; i <= k; i++) {
    for (int j = 1; j <= 26; j++) cnt[j] = 0;
    for (auto ch : str[i]) cnt[ch - 'a' + 1]++;
    for (int j = 1; j <= 26; j++) ans &= (main_cnt[j] == cnt[j]);
  }
  int all = 0, same_ones = 0;
  vector<int> diff;
  vector<pair<int, int> > swap_ops;
  if (ans) {
    for (int i = 2; i <= k; i++) {
      diff.clear();
      for (int j = 0; j < n && diff.size() <= 4; j++)
        if (str[i][j] != str[1][j]) diff.push_back(j);
      if (diff.size() > 4) {
        ans = false;
        break;
      }
      if (int(diff.size()) == 0)
        all++;
      else if (diff.size() == 2) {
        if (two) {
          same_ones++;
          swap_ops.push_back({diff[0], diff[1]});
          ind_cnt[diff[0]][diff[1]]++;
          ind_cnt[diff[1]][diff[0]]++;
        }
      } else if (diff.size() == 3) {
        int a = diff[0], b = diff[1], c = diff[2];
        ind_cnt[a][b]++;
        ind_cnt[b][a]++;
        ind_cnt[b][c]++;
        ind_cnt[c][b]++;
        ind_cnt[c][a]++;
        ind_cnt[a][c]++;
      } else {
        bool mila = false;
        for (int k1 = 0; k1 < 4 && !mila; k1++)
          for (int k2 = k1 + 1; k2 < 4 && !mila; k2++)
            if (str[1][diff[k1]] == str[i][diff[k2]] &&
                str[1][diff[k2]] == str[i][diff[k1]]) {
              mila = true;
              vector<int> other;
              for (int k3 = 0; k3 < 4; k3++)
                if (k3 != k1 && k3 != k2) other.push_back(k3);
              ind_cnt[diff[k1]][diff[k2]]++;
              ind_cnt[diff[k2]][diff[k1]]++;
              ind_cnt[diff[other[0]]][diff[other[1]]]++;
              ind_cnt[diff[other[1]]][diff[other[0]]]++;
            }
      }
    }
    for (auto item : swap_ops) {
      int a = item.first;
      int b = item.second;
      for (int j = 0; j < n; j++)
        if (j != a && str[1][j] == str[1][a])
          ind_cnt[b][j] = ind_cnt[j][b] += 1;
        else if (j != b && str[1][j] == str[1][b])
          ind_cnt[a][j] = ind_cnt[j][a] += 1;
    }
    bool mila = false;
    bool it = true;
    for (int i = 0; i < n && it; i++)
      for (int j = i + 1; j < n && it; j++) {
        if ((ind_cnt[i][j] + all + same_ones * (str[1][i] == str[1][j])) ==
            k - 1) {
          mila = true;
          swap(str[1][i], str[1][j]);
          it = false;
        }
      }
    ans &= mila;
  }
  if (ans)
    cout << str[1] << "\n";
  else
    printf("%d\n", -1);
  return 0;
}
