#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<char> > vals;
vector<vector<int> > mem;
void eliminateHor(int x, int y, char target);
void eliminateVert(int x, int y, char target);
void eliminateHor(int x, int y, char target) {
  if (mem[x][y] == 2) return;
  mem[x][y]++;
  for (int i = 0; i < m; i++) {
    if (vals[x][i] == target && i != y) {
      eliminateVert(x, i, target);
      vals[x][y] = ' ';
      vals[x][i] = ' ';
    }
  }
}
void eliminateVert(int x, int y, char target) {
  if (mem[x][y] == 2) return;
  mem[x][y]++;
  for (int i = 0; i < n; i++) {
    if (vals[i][y] == target && i != x) {
      eliminateHor(i, y, target);
      vals[i][y] = ' ';
      vals[x][y] = ' ';
    }
  }
}
int main(int argc, char *argv[]) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    vector<char> row;
    vector<int> row2;
    for (int j = 0; j < m; j++) {
      char num;
      cin >> num;
      row.push_back(num);
      row2.push_back(0);
    }
    vals.push_back(row);
    mem.push_back(row2);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char target = vals[i][j];
      eliminateVert(i, j, target);
      eliminateHor(i, j, target);
    }
  }
  string result = "";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vals[i][j] != ' ') cout << vals[i][j];
    }
  }
  cout << result << endl;
}
