#include <bits/stdc++.h>
using namespace std;
bool isNotRepeat(vector<string> grid, int y, int x) {
  for (int i = 0; i < grid.size(); i++)
    if (i != y && grid[i][x] == grid[y][x]) return false;
  for (int i = 0; i < grid[0].size(); i++)
    if (i != x && grid[y][i] == grid[y][x]) return false;
  return true;
}
int main() {
  vector<string> c;
  string ans;
  int x, y;
  cin >> y >> x;
  cin.ignore();
  for (int i = 0; i < y; i++) {
    string temp;
    getline(cin, temp);
    c.push_back(temp);
  }
  for (int i = 0; i < y; i++)
    for (int j = 0; j < x; j++)
      if (isNotRepeat(c, i, j)) ans += c[i][j];
  cout << ans << endl;
  return 0;
}
