#include <bits/stdc++.h>
using namespace std;
char Map[105][105];
int n, m;
bool Yes(int i, int j) {
  char c = Map[i][j];
  int num = 0;
  for (int k = 0; k < n; k++) {
    if (Map[k][j] == c) num++;
  }
  for (int k = 0; k < m; k++) {
    if (Map[i][k] == c) num++;
  }
  if (num > 2)
    return false;
  else
    return true;
}
int main() {
  int i, j;
  char c;
  int nc;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) {
      getchar();
      for (j = 0; j < m; j++) {
        scanf("%c", &Map[i][j]);
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (Yes(i, j)) printf("%c", Map[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}
