#include <bits/stdc++.h>
using namespace std;
int n, m;
char table[10000][10000];
bool mark[10000][10000];
void read() {
  for (int i = 0; i < n; i++) cin >> table[i];
}
void init() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      mark[i][j] = false;
    }
  }
}
void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < m; k++) {
        if (j != k) {
          if (table[i][j] == table[i][k]) {
            mark[i][k] = mark[i][j] = true;
          }
        }
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (j != k) {
          if (table[j][i] == table[k][i]) {
            mark[j][i] = mark[k][i] = true;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!mark[i][j]) cout << table[i][j];
    }
  }
}
int main() {
  cin >> n >> m;
  init();
  read();
  solve();
  return 0;
}
