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: H, W = map(int, input().split())
  
  grid = [list(str(input())) for _ in range(H)]
  
  
  def elim(grid):
      grid_after = []
      for i in range(H):
          gset = list(set(grid[i]))
          # print(gset)
          # print(grid[i])
          if gset[0] != ".":
              grid_after.append(grid[i])
      return grid_after
  
  
  def transpose(grid_after):
  
      H1 = len(grid_after)
      W1 = len(grid_after[0][:])
      gridT = [[""] * H1 for _ in range(W1)]
      for i in range(W1):
          for j in range(H1):
              gridT[i][j] = grid_after[j][i]
  
      return gridT
  
  
  grid_after = elim(grid)
  
  gridT1 = transpose(grid_after)
  # print(gridT1)
  grid_after2 = elim(gridT1)
  # print(grid_after2)
  gridT2 = transpose(grid_after2)
  # print(gridT2)
  for i in gridT2:
      print(*i, sep="")
  
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    #.#"}]