#include <bits/stdc++.h>
using namespace std;
bool flag;
vector<string> sp;
void gb(const string &s) {
  cout << s;
  exit(0);
}
bool f(const string &x) {
  for (int i = 1; i < sp.size(); i++) {
    vector<int> pos;
    for (int j = 0; j < sp[i].size(); j++)
      if (sp[i][j] != x[j]) pos.push_back(j);
    if (pos.size() == 2) {
      bool t = true;
      swap(sp[i][pos[0]], sp[i][pos[1]]);
      if (x != sp[i]) t = false;
      swap(sp[i][pos[0]], sp[i][pos[1]]);
      if (!t) return false;
    } else if (pos.size() == 0 && flag && sp[i] == x)
      continue;
    else
      return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  sp.resize(k);
  for (int i = 0; i < k; i++) cin >> sp[i];
  int ind = 0;
  for (int i = 1; i < k; i++)
    if (sp[i] != sp[0]) ind = i;
  if (sp[ind] == sp[0]) {
    swap(sp[0][0], sp[0][1]);
    gb(sp[0]);
  }
  vector<int> pos;
  for (int i = 0; i < n; i++)
    if (sp[0][i] != sp[ind][i]) pos.push_back(i);
  if (pos.size() > 4) {
    cout << -1;
    return 0;
  }
  int cnt[26] = {0};
  for (int i = 0; i < n; i++) cnt[sp[0][i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (cnt[i] > 1) flag = true;
  for (int i = 0; i < pos.size(); i++) {
    for (int j = i + 1; j < pos.size(); j++) {
      swap(sp[0][pos[i]], sp[0][pos[j]]);
      if (f(sp[0])) gb(sp[0]);
      swap(sp[0][pos[i]], sp[0][pos[j]]);
    }
  }
  if (flag && f(sp[0])) gb(sp[0]);
  cout << -1;
  return 0;
}
