#include <bits/stdc++.h>
using namespace std;
set<string> s;
set<string>::iterator it;
int ck;
map<char, int> name, name2;
int get(string dec) {
  for (it = s.begin(); it != s.end(); it++) {
    string c = *it;
    int cnt = 0;
    for (int j = 0; dec[j]; j++) {
      if (dec[j] != c[j]) cnt++;
    }
    if (cnt == 0 && ck == 0) return 0;
    ;
    if (cnt % 2 || cnt > 2) return 0;
  }
  return 1;
}
int main() {
  int i, j, k, l, m, n;
  cin >> k >> n;
  string st, gt, ds;
  cin >> st;
  gt.clear();
  if (k == 1) {
    swap(st[0], st[1]);
    cout << st << endl;
    return 0;
  }
  s.insert(st);
  for (int i = 1; i < k; i++) {
    cin >> ds;
    if (s.find(ds) == s.end() && gt.size() == 0) {
      gt = ds;
      s.insert(ds);
      continue;
    }
    s.insert(ds);
  }
  if (s.size() == 1) {
    swap(st[0], st[1]);
    cout << st << endl;
    return 0;
  }
  vector<int> vc;
  for (int i = 0; i < n; i++) {
    if (st[i] != gt[i]) vc.push_back(i);
    name[st[i]]++;
    name2[gt[i]]++;
  }
  if (vc.size() > 4 || vc.size() == 1) {
    cout << "-1";
    return 0;
  }
  for (int i = 97; i <= 122; i++) {
    if (name[i] != name2[i]) {
      cout << "-1";
      return 0;
    }
    ck |= (name[i] > 1);
  }
  for (int i = 0; i < vc.size(); i++) {
    int l = vc[i];
    for (int k = 0; k < n; k++) {
      if (l == k) continue;
      string dec = st;
      swap(dec[l], dec[k]);
      if (get(dec)) {
        cout << dec << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < vc.size(); i++) {
    int l = vc[i];
    for (int k = 0; k < n; k++) {
      if (l == k) continue;
      string dec = gt;
      swap(dec[l], dec[k]);
      if (get(dec)) {
        cout << dec << endl;
        return 0;
      }
    }
  }
  cout << "-1";
}
