import std.stdio, std.string, std.algorithm, std.conv, std.array, std.math, std.container, std.range;

void main(){
  auto hw = readln.split.map!(to!int);
  string[] arr;
  foreach(i;0..hw[0]){
    auto line = readln.chomp;
    if(line.any!"a=='#'")arr~=line;
  }

  string[] sw;
  foreach(col;iota(0, hw[1]).map!(i=>arr.transversal(i)))
  {
    if(col.any!"a=='#'")sw~=col.array;
  }

  foreach(line;iota(0, arr.length).map!(i=>sw.transversal(i)))line.writeln;
}