#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from numpy import*\n"
"h,w=int8(input().split())\n"
"a=array(eval('list(input()),'*h))\n"
"print(*map(''.join,a[any(a<'.',1)][:,any(a<'.',0)]))\n"
"\"";
  system(s);
  return 0;
}            