public static void main ( String [ ] args ) {
  try ( Scanner scan = new Scanner ( System . in ) ) {
    int n = scan . nextInt ( ) ;
    int m = scan . nextInt ( ) ;
    scan . nextLine ( ) ;
    boolean [ ] [ ] grid = new boolean [ n ] [ m ] ;
    int minJ = m , maxJ = - 1 , minI = n , maxI = - 1 ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      String line = scan . nextLine ( ) ;
      for ( int j = 0 ;
      j < m ;
      j ++ ) {
        grid [ i ] [ j ] = line . charAt ( j ) == '*' ;
        if ( grid [ i ] [ j ] ) {
          minJ = Math . min ( j , minJ ) ;
          maxJ = Math . max ( j , maxJ ) ;
          minI = Math . min ( i , minI ) ;
          maxI = Math . max ( i , maxI ) ;
        }
      }
    }
    for ( int i = minI ;
    i <= maxI ;
    i ++ ) {
      for ( int j = minJ ;
      j <= maxJ ;
      j ++ ) System . out . print ( grid [ i ] [ j ] ? '*' : '.' ) ;
      System . out . println ( ) ;
    }
  }
}

public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int n = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; scan . nextLine ( ) ; boolean [ ] [ ] grid = new boolean [ n ] [ m ] ; int minJ = m , maxJ = - 1 , minI = n , maxI = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { String line = scan . nextLine ( ) ; for ( int j = 0 ; j < m ; j ++ ) { grid [ i ] [ j ] = line . charAt ( j ) == ' * ' ; if ( grid [ i ] [ j ] ) { minJ = Math . min ( j , minJ ) ; maxJ = Math . max ( j , maxJ ) ; minI = Math . min ( i , minI ) ; maxI = Math . max ( i , maxI ) ; } } } for ( int i = minI ; i <= maxI ; i ++ ) { for ( int j = minJ ; j <= maxJ ; j ++ ) System . out . print ( grid [ i ] [ 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 (try_with_resources_statement resources: (resource_specification (resource type: (type_identifier) name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (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)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (local_variable_declaration type: (array_type element: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (identifier)) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier)) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (identifier)) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) 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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal)))) (if_statement condition: (parenthesized_expression (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (ternary_expression condition: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) consequence: (character_literal) alternative: (character_literal)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list)))))))))