#include <bits/stdc++.h>
using namespace std;
void print(vector<int> a, int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  char a[n][m];
  char b[n][m];
  char c[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j];
      c[i][j] = a[i][j];
    }
  }
  vector<pair<char, int>> v3;
  for (int i = 0; i < n; i++) {
    map<char, int> mb;
    for (int j = 0; j < m; j++) {
      mb[b[i][j]]++;
      if (mb[b[i][j]] > 1) {
        v3.push_back({b[i][j], i});
        b[i][j] = '*';
      }
    }
  }
  for (int i = 0; i < m; i++) {
    map<char, int> mc;
    for (int j = 0; j < n; j++) {
      mc[c[j][i]]++;
      if (mc[c[j][i]] > 1) {
        char ch = c[j][i];
        c[j][i] = '*';
        for (int k = 0; k < n; k++) {
          if (c[k][i] == ch) {
            c[k][i] = '*';
          }
        }
      }
    }
  }
  for (int i = 0; i < v3.size(); i++) {
    for (int j = 0; j < m; j++) {
      if (b[v3[i].second][j] == v3[i].first) {
        b[v3[i].second][j] = '*';
      }
    }
  }
  string ans = "";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i][j] != '*' && c[i][j] != '*') {
        ans += a[i][j];
      }
    }
  }
  cout << ans;
}
