#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, J, I, m, sum1 = 0, sum2 = 0;
  cin >> n >> m;
  string x[n];
  char s;
  vector<char> v;
  for (int i = 0; i < n; i++) cin >> x[i];
  cout << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      s = x[i][j];
      I = i;
      J = j;
      for (int k = 0; k < n; k++)
        if (x[k][J] == s) sum1++;
      for (int j = 0; j < m; j++)
        if (x[I][j] == s) sum2++;
      if (sum1 <= 1 && sum2 <= 1) {
        for (int i = 0; i < n; i++)
          if (x[i][J] == s) v.push_back(x[i][J]);
      }
      sum1 = 0;
      sum2 = 0;
    }
  }
  for (int i = 0; i < v.size(); i++) cout << v[i];
}
