public static void main ( String [ ] args ) {
  int h = scanner . nextInt ( ) ;
  int w = scanner . nextInt ( ) ;
  String [ ] a = Stream . generate ( ( ) -> null ) . limit ( h ) . map ( b -> scanner . next ( ) ) . filter ( b -> b . contains ( "#" ) ) . toArray ( String [ ] :: new ) ;
  List < Integer > i = IntStream . range ( 0 , w ) . boxed ( ) . collect ( Collectors . toList ( ) ) ;
  for ( String s : a ) i . removeIf ( i2 -> s . charAt ( i2 ) == '#' ) ;
  for ( String s : a ) {
    char [ ] c = s . toCharArray ( ) ;
    for ( int j = 0 ;
    j < c . length ;
    j ++ ) if ( ! i . contains ( j ) ) System . out . print ( c [ j ] ) ;
    System . out . println ( ) ;
  }
}

public static void main ( String [ ] args ) { int h = scanner . nextInt ( ) ; int w = scanner . nextInt ( ) ; String [ ] a = Stream . generate ( ( ) -> null ) . limit ( h ) . map ( b -> scanner . next ( ) ) . filter ( b -> b . contains ( " # " ) ) . toArray ( String [ ] :: new ) ; List < Integer > i = IntStream . range ( 0 , w ) . boxed ( ) . collect ( Collectors . toList ( ) ) ; for ( String s : a ) i . removeIf ( i2 -> s . charAt ( i2 ) == ' # ' ) ; for ( String s : a ) { char [ ] c = s . toCharArray ( ) ; for ( int j = 0 ; j < c . length ; j ++ ) if ( ! i . contains ( j ) ) System . out . print ( c [ j ] ) ; System . out . println ( ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (lambda_expression parameters: (formal_parameters) body: (null_literal)))) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))))) name: (identifier) arguments: (argument_list (method_reference (array_type element: (type_identifier) dimensions: (dimensions))))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list)))))))