#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4786)
using namespace std;
int MIN(int a, int b) { return a < b ? a : b; }
int MAX(int a, int b) { return a > b ? a : b; }
int GCD(int a, int b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
int LCM(int a, int b) { return a * (b / GCD(a, b)); }
void SWAP(int &a, int &b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
const double PI = acos(-1);
const double ESP = 1e-11;
char arr[1000][1000];
int brr[1000][1000];
int main() {
  int ind, i, j, N, T, result, cnt, counter, temp, temp1, idx, index, k, l, n,
      m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(arr, NULL, sizeof(arr));
    memset(brr, 0, sizeof(brr));
    for (i = 0; i < n; i++) {
      scanf("%s", &arr[i]);
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        int c = (int)arr[i][j];
        cnt = 0;
        for (k = 0; k < n; k++) {
          if ((int)arr[k][j] == c) {
            cnt += 1;
          }
        }
        for (k = 0; k < m; k++) {
          if ((int)arr[i][k] == c) {
            cnt += 1;
          }
        }
        if (cnt >= 3) {
          for (k = 0; k < n; k++) {
            if ((int)arr[k][j] == c) {
              brr[k][j] = -1;
            }
          }
          for (k = 0; k < m; k++) {
            if ((int)arr[i][k] == c) {
              brr[i][k] = -1;
            }
          }
        }
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (brr[i][j] != -1) {
          printf("%c", arr[i][j]);
        }
      }
    }
    printf("\n");
  }
  return 0;
}
