#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
vector<string> v;
int n, m;
bool check(int i, int j) {
  for (int k = 0; k < m; k++) {
    if (k == j) continue;
    if (v[i][j] == v[i][k]) return false;
  }
  for (int k = 0; k < n; k++) {
    if (k == i) continue;
    if (v[i][j] == v[k][j]) return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  string res = "";
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (check(i, j)) res += v[i][j];
    }
  }
  cout << res;
}
