#include <bits/stdc++.h>
using namespace std;
const int maxK = 2511;
int k, n, dif[maxK], app[maxK][30];
bool seem;
string s[maxK];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> k >> n;
  for (int i = 1; i <= k; i++) {
    cin >> s[i];
    s[i] = " " + s[i];
    for (int j = 1; j <= n; j++) {
      int id = s[i][j] - 'a' + 1;
      app[i][id]++;
    }
  }
  for (int i = 2; i <= k; i++)
    for (int j = 1; j <= 26; j++)
      if (app[1][j] != app[i][j]) {
        cout << -1;
        exit(0);
      }
  for (int j = 1; j <= 26; j++)
    if (app[1][j] > 1) {
      seem = true;
      break;
    }
  for (int i = 2; i <= k; i++)
    for (int j = 1; j <= n; j++)
      if (s[1][j] != s[i][j]) dif[i]++;
  for (int u = 1; u <= n - 1; u++)
    for (int v = u + 1; v <= n; v++) {
      bool check = true;
      for (int i = 2; i <= k; i++) {
        int nw = dif[i];
        if (s[1][u] == s[i][u]) nw++;
        if (s[1][v] == s[i][v]) nw++;
        if (s[1][u] == s[i][v]) nw--;
        if (s[1][v] == s[i][u]) nw--;
        if (nw == 2) continue;
        if (nw == 0 && (seem)) continue;
        check = false;
        break;
      }
      if (check) {
        for (int j = 1; j <= n; j++) {
          if (j == u) {
            cout << s[1][v];
            continue;
          }
          if (j == v) {
            cout << s[1][u];
            continue;
          }
          cout << s[1][j];
        }
        exit(0);
      }
    }
  cout << -1;
  return 0;
}
