#include <bits/stdc++.h>
using namespace std;
char a[1000][1000];
int vis[1000][1000];
int n, m;
int f(int x, int y) {
  int flag = 0;
  for (int i = 0; i < n; i++)
    if (i != x && a[i][y] == a[x][y]) {
      vis[i][y] = 1;
      flag = 1;
    }
  for (int i = 0; i < m; i++)
    if (i != y && a[x][i] == a[x][y]) {
      vis[x][i] = 1;
      flag = 1;
    }
  return flag;
}
int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> a[i][j];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (f(i, j)) vis[i][j] = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (!vis[i][j]) cout << a[i][j];
    cout << endl;
  }
  return 0;
}
