#include <bits/stdc++.h>
using namespace std;
void solve() {
  vector<string> s;
  int k, n, good = 1;
  cin >> k >> n;
  for (int i = 0; i < k; i++) {
    string temp;
    cin >> temp;
    int g = 0;
    for (int j = 0; j < (int)s.size(); j++)
      if (s[j] == temp) g = 1;
    if (!g) s.push_back(temp);
  }
  for (int i = 0; i < (int)s.size(); i++)
    for (int j = i + 1; j < (int)s.size(); j++) {
      string t1 = s[i];
      string t2 = s[j];
      sort((t1).begin(), (t1).end());
      sort((t2).begin(), (t2).end());
      if (t1 != t2) good = 0;
    }
  if (!good) {
    cout << -1;
    return;
  }
  int v[26] = {0}, ans = 0, flag = 0;
  for (int i = 0; i < n; i++) {
    v[s[0][i] - 'a']++;
    if (v[s[0][i] - 'a'] > 1) flag = 1;
  }
  if ((int)s.size() == 1) {
    swap(s[0][1], s[0][0]);
    cout << s[0];
    return;
  }
  int p1;
  for (int i = 0; i < n; i++)
    if (s[0][i] != s[1][i]) {
      p1 = i;
      break;
    }
  for (int i = 0; i < n; i++) {
    if (i == p1) continue;
    int f = 1;
    string temp = s[0];
    swap(temp[p1], temp[i]);
    set<pair<int, int> > st;
    for (int j = 0; j < (int)s.size(); j++) {
      int cnt = 0;
      vector<int> vv;
      if (s[j] == temp) {
        if (!flag) {
          f = 0;
          break;
        }
        continue;
      }
      for (int l = 0; l < n; l++)
        if (s[j][l] != temp[l]) vv.push_back(l);
      if ((int)vv.size() > 2) {
        f = 0;
        break;
      }
      if (st.count({vv[0], vv[1]})) {
        f = 0;
        break;
      }
      st.insert({vv[0], vv[1]});
      st.insert({vv[1], vv[0]});
    }
    if (!f) continue;
    cout << temp;
    return;
  }
  swap(s[0], s[1]);
  for (int i = 0; i < n; i++) {
    if (i == p1) continue;
    int f = 1;
    string temp = s[0];
    swap(temp[p1], temp[i]);
    set<pair<int, int> > st;
    for (int j = 0; j < (int)s.size(); j++) {
      int cnt = 0;
      vector<int> vv;
      if (s[j] == temp) {
        if (!flag) {
          f = 0;
          break;
        }
        continue;
      }
      for (int l = 0; l < n; l++)
        if (s[j][l] != temp[l]) vv.push_back(l);
      if ((int)vv.size() > 2) {
        f = 0;
        break;
      }
      if (st.count({vv[0], vv[1]})) {
        f = 0;
        break;
      }
      st.insert({vv[0], vv[1]});
      st.insert({vv[1], vv[0]});
    }
    if (!f) continue;
    cout << temp;
    return;
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
