#include <bits/stdc++.h>
const double PI(acos(-1.0));
const double PI_2 = PI * 2.0;
double eps = 1e-9;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<map<char, int> > I(n), J(m);
  vector<vector<char> > v(n, vector<char>(m));
  for (long long(i) = (0); i <= (((long long)n) - 1); ++(i))
    for (long long(j) = (0); j <= (((long long)m) - 1); ++(j)) cin >> v[i][j];
  for (long long(i) = (0); i <= (((long long)n) - 1); ++(i)) {
    for (long long(j) = (0); j <= (((long long)m) - 1); ++(j)) {
      I[i][v[i][j]]++;
      J[j][v[i][j]]++;
    }
  }
  for (long long(i) = (0); i <= (((long long)n) - 1); ++(i)) {
    for (long long(j) = (0); j <= (((long long)m) - 1); ++(j)) {
      if (I[i][v[i][j]] == 1 && J[j][v[i][j]] == 1) cout << v[i][j];
    }
  }
  return 0;
}
