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 __future__ import print_function
  
  # import numpy as np
  # import numpypy as np
  import sys
  
  input = sys.stdin.readline
  
  
  def eprint(*args, **kwargs):
      print(*args, file=sys.stderr, **kwargs)
      return
  
  
  import math
  import string
  import fractions
  from fractions import Fraction
  from fractions import gcd
  
  
  def lcm(n, m):
      return int(n * m / gcd(n, m))
  
  
  import re
  import array
  import copy
  import functools
  import operator
  
  import collections
  import itertools
  import bisect
  import heapq
  
  
  from heapq import heappush
  from heapq import heappop
  from heapq import heappushpop
  from heapq import heapify
  from heapq import heapreplace
  
  from queue import PriorityQueue as pq
  
  
  def reduce(p, q):
      common = fractions.gcd(p, q)
      return (p // common, q // common)
  
  
  # from itertools import accumulate
  # from collections import deque
  
  from operator import mul
  from functools import reduce
  
  
  def combinations_count(n, r):
      r = min(r, n - r)
      numer = reduce(mul, range(n, n - r, -1), 1)
      denom = reduce(mul, range(1, r + 1), 1)
      return numer // denom
  
  
  import random
  
  
  def main():
      h, w = map(int, input().strip().split())
      g = [input().strip() for _ in range(h)]
      gg = [col for col in zip(*g) if ("#" in col)]
  
      eprint("gg ", end=": \n")
      eprint(gg)
      for elem in gg:
          eprint(elem)
  
      gg = [row for row in zip(*gg) if ("#" in row)]
      eprint("gg ", end=": \n")
      eprint(gg)
      # for elem in gg:
      #     eprint(elem)
  
      for S in gg:
          print("".join(S))
      return
  
  
  if __name__ == "__main__":
      main()
  
  
  # trA  = [list(col) for col in zip(*A)]
  
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    #.#"}]