#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e3 + 19;
const int inf = INT_MAX - 19;
const int mod = 1000000007LL;
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  string s[maxx] = {};
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int tmp = 0;
      for (int k = 0; k < n; k++)
        if (s[k][j] == s[i][j]) tmp++;
      for (int k = 0; k < m; k++)
        if (s[i][k] == s[i][j]) tmp++;
      if (tmp == 2) cout << s[i][j];
    }
  }
  return 0;
}
