INTEGER H,W,CHECK
CHARACTER(200),ALLOCATABLE,DIMENSION(:)::S
READ*,H,W
ALLOCATE(S(H))
READ*,S
DO I=W,1,-1
  CHECK=0
  DO J=1,H
    IF(S(J)(I:I)=="#") CHECK=1
  END DO
  IF (CHECK==0)THEN
    DO J=1,H
    S(J)=TRIM(S(J)(1:I-1))//TRIM(S(J)(I+1:W))
    END DO
  END IF
END DO
DO J=1,H
  IF(TRIM(S(J))/=REPEAT(".", LEN_TRIM(S(J)) ) )PRINT"(A)",TRIM(S(J))
END DO
END
