#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int MAX = 1e9 + 10;
const int N = 1e5 + 5;
const int J = 550;
const int K = 5500;
int n, k, minI{55}, minJ{55}, maxI{-1}, maxJ{-1};
char x;
int main() {
  cin >> n >> k;
  char arr[n][k];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == '*') {
        if (i < minI) minI = i;
        if (j < minJ) minJ = j;
        if (i > maxI) maxI = i;
        if (j > maxJ) maxJ = j;
      }
    }
  }
  for (int i = minI; i <= maxI; i++) {
    for (int j = minJ; j <= maxJ; j++) {
      cout << arr[i][j];
    }
    cout << endl;
  }
}
