#include <bits/stdc++.h>
using namespace std;
struct price {
  int a, b, c, d, e;
};
bool comp(pair<int, int> x, pair<int, int> y) { return x.first > y.first; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  int arr[n][m];
  memset(arr, 1, sizeof(arr));
  for (int i = 0; i < n; i++) cin >> s[i];
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s[i][j] != 'X') {
        char a = s[i][j];
        bool isthere = 0;
        for (int k = 0; k < n; k++) {
          if (k == i) continue;
          if (s[k][j] == a) {
            arr[k][j] = 0;
            isthere = 1;
          }
        }
        for (int k = 0; k < m; k++) {
          if (k == j) continue;
          if (s[i][k] == a) {
            arr[i][k] = 0;
            isthere = 1;
          }
        }
        if (isthere == 1) arr[i][j] = 0;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (arr[i][j]) cout << s[i][j];
    }
  }
}
