#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1;
map<pair<long long, long long>, long long> mp, pm;
deque<long long> v, vc, ve;
deque<char> p, pe;
deque<string> ts, ss;
deque<double> sd;
long long a, b, c, d, e, f, cnt, ans, r, n, l;
long double q, t, cnt1;
string g, h, w, o, z, m, s;
char y, u;
bool re, rt;
set<long long> st;
vector<pair<long long, long long> > pr, rp;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin >> a >> b;
  char arr[a][b];
  for (long long i = 0; i < a; i++) {
    cin >> g;
    for (long long j = 0; j < g.size(); j++) arr[i][j] = g[j];
  }
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      for (long long k = 0; k < b; k++) {
        if (j != k and (arr[i][j] == arr[i][k])) {
          mp[{i, j}]++;
          mp[{i, k}]++;
          if (mp[{i, j}] == 1) pr.push_back({i, j});
          if (mp[{i, k}] == 1) pr.push_back({i, k});
        }
      }
    }
  }
  for (long long i = 0; i < b; i++) {
    for (long long j = 0; j < a; j++) {
      for (long long k = 0; k < a; k++) {
        if (j != k and (arr[j][i] == arr[k][i])) {
          mp[{j, i}]++;
          mp[{k, i}]++;
          if (mp[{j, i}] == 1) pr.push_back({j, i});
          if (mp[{k, i}] == 1) pr.push_back({k, i});
        }
      }
    }
  }
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      cnt = 0;
      for (long long k = 0; k < pr.size(); k++) {
        if (i == pr[k].first and j == pr[k].second) {
          cnt++;
          break;
        }
      }
      if (cnt == 0) cout << arr[i][j];
    }
  }
}
