#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const int mod = 1e9 + 7;
using namespace std;
template <class T>
void cinn(T& x) {
  cin >> x;
}
template <class H, class... T>
void cinn(H& h, T&... t) {
  cinn(h);
  cinn(t...);
}
template <class A>
void cinn(vector<A>& x) {
  for (auto& a : x) cinn(a);
}
void Shazam() {
  int a, b;
  cinn(a, b);
  char s[a][b];
  map<int, vector<char>> mr, mc;
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      cin >> s[i][j];
      mr[i].push_back(s[i][j]);
      mc[j].push_back(s[i][j]);
    }
  }
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      char x = s[i][j];
      if (count(mr[i].begin(), mr[i].end(), x) > 1 ||
          count(mc[j].begin(), mc[j].end(), x) > 1)
        s[i][j] = '?';
    }
  }
  string ans = "";
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      if (s[i][j] != '?') ans += s[i][j];
    }
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    Shazam();
  }
  return 0;
}
