#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 2e6 + 7, M = 2e6 + 7, INF = INT_MAX / 10;
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
int n, l;
vector<string> arr;
int my_hash[26];
bool check(string &cur) {
  bool dup = false;
  memset(my_hash, 0, sizeof my_hash);
  for (int i = 0; i < l; i++) {
    my_hash[cur[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)
    if (my_hash[i] > 1) {
      dup = true;
      break;
    }
  for (auto &x : arr) {
    int ctr = 0;
    vector<int> pos;
    for (int i = 0; i < l; i++) {
      if (x[i] != cur[i]) ctr++, pos.push_back(i);
    }
    if (ctr == 2 && cur[pos[0]] == x[pos[1]] && cur[pos[1]] == x[pos[0]])
      continue;
    if (ctr == 0 && dup) continue;
    return false;
  }
  return true;
}
void solve() {
  cin >> n >> l;
  arr.resize(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  string s1, s2;
  bool found = false;
  int ind = -1;
  for (int i = 0; i < n && (!found); i++) {
    for (int j = i + 1; j < n && (!found); j++) {
      if (arr[i] == arr[j]) continue;
      found = true;
      s1 = arr[i], s2 = arr[j];
      for (int k = 0; k < l; k++) {
        if (arr[i][k] != arr[j][k]) {
          ind = k;
          break;
        }
      }
    }
  }
  if (!found) {
    string ans = arr[0];
    swap(ans[0], ans[1]);
    cout << ans;
    return;
  }
  string ans = "";
  for (int k = 0; k < 2 && ans.size() == 0; k++) {
    string candidate = s1;
    for (int i = 0; i < l; i++) {
      swap(candidate[i], candidate[ind]);
      if (check(candidate)) {
        ans = candidate;
        break;
      }
      swap(candidate[i], candidate[ind]);
    }
    swap(s1, s2);
  }
  if (ans.size())
    cout << ans;
  else
    cout << "-1\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
