#include <bits/stdc++.h>
using namespace std;
int intcmp(const void *v1, const void *v2) { return *(int *)v1 - *(int *)v2; }
long long minn(long long v1, long long v2) { return v1 < v2 ? v1 : v2; }
long long maxx(long long v1, long long v2) { return v1 > v2 ? v1 : v2; }
string s[3000];
string res;
int lunhuan;
int k, n;
int diff2(string &s1, string &s2) {
  int ret = -1;
  for (int i = 0; i < n; i++) {
    if (s1[i] != s2[i]) {
      if (ret == -1)
        ret = i;
      else if (ret < 0)
        return -1;
      else {
        if (s1[i] == s2[ret] && s1[ret] == s2[i])
          ret = -1000;
        else
          return -1;
      }
    }
  }
  return ret == -1 ? 0 : (ret == -1000 ? 2 : 1);
}
string ans = "";
bool check() {
  for (int i = 0; i < k; i++) {
    int r = diff2(ans, s[i]);
    if (r == 2) continue;
    if (r == 0 && lunhuan) continue;
    return false;
  }
  return true;
}
void doswap(int i, int j) {
  char ch = ans[i];
  ans[i] = ans[j];
  ans[j] = ch;
}
bool countlunhuan(string &sl) {
  int charcnt[30] = {0};
  for (int i = 0; i < n; i++) charcnt[sl[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (charcnt[i] > 1) return true;
  return false;
}
vector<int> getdiff(string &s1, string &s2) {
  vector<int> ret;
  for (int i = 0; i < n; i++) {
    if (s1[i] != s2[i]) {
      ret.push_back(i);
      if (ret.size() > 4) return ret;
    }
  }
  return ret;
}
void op2(vector<int> indexs) {
  for (int i = 0; i < n; i++) {
    doswap(i, indexs[0]);
    if (check()) {
      cout << ans << endl;
      return;
    }
    doswap(i, indexs[0]);
  }
  for (int i = 0; i < n; i++) {
    doswap(i, indexs[1]);
    if (check()) {
      cout << ans << endl;
      return;
    }
    doswap(i, indexs[1]);
  }
  cout << -1 << endl;
}
void op34(vector<int> indexs) {
  for (int i = 0; i < indexs.size(); i++)
    for (int j = i + 1; j < indexs.size(); j++) {
      doswap(indexs[i], indexs[j]);
      if (check()) {
        cout << ans << endl;
        return;
      }
      doswap(indexs[i], indexs[j]);
    }
  cout << -1 << endl;
}
void op(vector<int> indexs) {
  switch (indexs.size()) {
    case 2:
      op2(indexs);
      break;
    case 3:
    case 4:
      op34(indexs);
      break;
    default:
      cout << -1 << endl;
  }
}
int main() {
  cin >> k >> n;
  for (int i = 0; i < k; i++) cin >> s[i];
  lunhuan = countlunhuan(s[0]);
  ans = s[0];
  int diffcode = 0;
  for (int i = 1; i < k; i++) {
    vector<int> ret = getdiff(ans, s[i]);
    if (ret.size() != 0) {
      op(ret);
      return 0;
    }
  }
  doswap(0, 1);
  cout << ans << endl;
  return 0;
}
