output_description: Print the final state of the grid in the same format as input (without the
  numbers of rows and columns); see the samples for clarity.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W
      a_{1, 1}...a_{1, W}
      :
      a_{H, 1}...a_{H, W}
attempt: ###############################################################################
  
  from sys import stdout
  from bisect import bisect_left as binl
  from copy import copy, deepcopy
  
  
  mod = 1
  
  
  def intin():
      input_tuple = input().split()
      if len(input_tuple) <= 1:
          return int(input_tuple[0])
      return tuple(map(int, input_tuple))
  
  
  def intina():
      return [int(i) for i in input().split()]
  
  
  def intinl(count):
      return [intin() for _ in range(count)]
  
  
  def modadd(x, y):
      global mod
      return (x + y) % mod
  
  
  def modmlt(x, y):
      global mod
      return (x * y) % mod
  
  
  def lcm(x, y):
      while y != 0:
          z = x % y
          x = y
          y = z
      return x
  
  
  def combination(x, y):
      assert x >= y
  
      if y > x // 2:
          y = x - y
  
      ret = 1
  
      for i in range(0, y):
          j = x - i
          i = i + 1
  
          ret = ret * j
          ret = ret // i
  
      return ret
  
  
  def get_divisors(x):
      retlist = []
      for i in range(1, int(x**0.5) + 3):
          if x % i == 0:
              retlist.append(i)
              retlist.append(x // i)
      return retlist
  
  
  def get_factors(x):
      retlist = []
      for i in range(2, int(x**0.5) + 3):
          while x % i == 0:
              retlist.append(i)
              x = x // i
      retlist.append(x)
      return retlist
  
  
  def make_linklist(xylist):
      linklist = {}
      for a, b in xylist:
          linklist.setdefault(a, [])
          linklist.setdefault(b, [])
          linklist[a].append(b)
          linklist[b].append(a)
      return linklist
  
  
  def calc_longest_distance(linklist, v=1):
      distance_list = {}
      distance_count = 0
      distance = 0
      vlist_previous = []
      vlist = [v]
      nodecount = len(linklist)
  
      while distance_count < nodecount:
          vlist_next = []
          for v in vlist:
              distance_list[v] = distance
              distance_count += 1
              vlist_next.extend(linklist[v])
          distance += 1
          vlist_to_del = vlist_previous
          vlist_previous = vlist
          vlist = list(set(vlist_next) - set(vlist_to_del))
  
      max_distance = -1
      max_v = None
      for v, distance in distance_list.items():
          if distance > max_distance:
              max_distance = distance
              max_v = v
  
      return (max_distance, max_v)
  
  
  def calc_tree_diameter(linklist, v=1):
      _, u = calc_longest_distance(linklist, v)
      distance, _ = calc_longest_distance(linklist, u)
      return distance
  
  
  ###############################################################################
  
  
  def main():
      h, w = intin()
      alistlist = []
      for i in range(h):
          alistlist.append(input())
  
      new_alistlist = []
      new_h = 0
      for alist in alistlist:
          if alist != "." * w:
              new_alistlist.append(alist)
              new_h += 1
      alistlist = new_alistlist
      h = new_h
  
      remove_wlist = []
      for i in range(w):
          for j in range(h):
              if alistlist[j][i] == "#":
                  break
          else:
              remove_wlist.append(i)
  
      new_alistlist = []
      for alist in alistlist:
          new_alist = ""
          for i in range(w):
              if i not in remove_wlist:
                  new_alist += alist[i]
          new_alistlist.append(new_alist)
      alistlist = new_alistlist
  
      for alist in alistlist:
          print(alist)
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  There is a grid of squares with H horizontal rows and W vertical columns. The
  square at the i-th row from the top and the j-th column from the left is
  represented as (i, j). Each square is black or white. The color of the square
  is given as an H-by-W matrix (a_{i, j}). If a_{i, j} is `.`, the square (i, j)
  is white; if a_{i, j} is `#`, the square (i, j) is black.
  
  Snuke is compressing this grid. He will do so by repeatedly performing the
  following operation while there is a row or column that consists only of white
  squares:
  
    * Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.
  
  It can be shown that the final state of the grid is uniquely determined
  regardless of what row or column is chosen in each operation. Find the final
  state of the grid.
samples: [{"input": "4 4\n    ##.#\n    ....\n    ##.#\n    .#.#", "output": "###\n    ###\n    .##\n    \n\nThe second row and the third column in the original grid will be removed.\n\n* * *"}, {"input": "3 3\n    #..\n    .#.\n    ..#", "output": "#..\n    .#.\n    ..#\n    \n\nAs there is no row or column that consists only of white squares, no operation\nwill be performed.\n\n* * *"}, {"input": "4 5\n    .....\n    .....\n    ..#..\n    .....", "output": "#\n    \n\n* * *"}, {"input": "7 6\n    ......\n    ....#.\n    .#....\n    ..#...\n    ..#...\n    ......\n    .#..#.", "output": "..#\n    #..\n    .#.\n    .#.\n    #.#"}]