const main = function(input){
  var nums = input.trim().split("\n")[0].split(" ").map(i=>parseInt(i));
  var H = nums[0];
  var W = nums[1];
  var board = input.trim().split("\n").slice(1);
  
  var delRowNums = [];
  for(var i=H-1;i>=0;i--){
  	var whiteRow = true;
    for(var j=0;j<W;j++){
      var char = board[i][j];
      if(char==="#"){
        whiteRow = false;
        break;
      }
    }
    if(whiteRow) board.splice(i,1);
  }
  H = board.length;
  for(var i=W-1;i>=0;i--){
    var whiteCol = true;
    for(var j=0;j<H;j++){
      var char = board[j][i];
      if(char==="#"){
        whiteCol = false;
        break;
      }
    }
    if(whiteCol){
      for(var j=0;j<H;j++){
        board[j] = board[j].slice(0,i)+ board[j].slice(i+1);
      }
    }
  }
  
  for(var i=0;i<H;i++){
    console.log(board[i]);
  }
  
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));