public static void main ( String [ ] args ) {
  try ( Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ) {
    int tests = sc . nextInt ( ) ;
    outer : for ( int t = 1 ;
    t <= tests ;
    t ++ ) {
      char [ ] happyChars = sc . next ( ) . toCharArray ( ) ;
      int spatWidth = sc . nextInt ( ) ;
      boolean [ ] happy = new boolean [ happyChars . length ] ;
      for ( int x = 0 ;
      x < happy . length ;
      x ++ ) happy [ x ] = happyChars [ x ] == '+' ;
      List < Integer > flipPoints = new LinkedList < Integer > ( ) ;
      int flipCount = 0 ;
      boolean flipped = false ;
      for ( int x = 0 ;
      x <= happy . length - spatWidth ;
      x ++ ) {
        if ( ! flipPoints . isEmpty ( ) && flipPoints . get ( 0 ) == x ) {
          flipPoints . remove ( 0 ) ;
          flipped = ! flipped ;
        }
        boolean current = happy [ x ] != flipped ;
        if ( ! current ) {
          flipped = ! flipped ;
          flipCount ++ ;
          flipPoints . add ( x + spatWidth ) ;
        }
      }
      for ( int x = happy . length - spatWidth + 1 ;
      x < happy . length ;
      x ++ ) {
        if ( ! flipPoints . isEmpty ( ) && flipPoints . get ( 0 ) == x ) {
          flipPoints . remove ( 0 ) ;
          flipped = ! flipped ;
        }
        if ( happy [ x ] == flipped ) {
          System . out . printf ( "Case #%d: IMPOSSIBLE%n" , t ) ;
          continue outer ;
        }
      }
      System . out . printf ( "Case #%d: %d%n" , t , flipCount ) ;
    }
  }
}

public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ) { int tests = sc . nextInt ( ) ; outer : for ( int t = 1 ; t <= tests ; t ++ ) { char [ ] happyChars = sc . next ( ) . toCharArray ( ) ; int spatWidth = sc . nextInt ( ) ; boolean [ ] happy = new boolean [ happyChars . length ] ; for ( int x = 0 ; x < happy . length ; x ++ ) happy [ x ] = happyChars [ x ] == ' + ' ; List < Integer > flipPoints = new LinkedList < Integer > ( ) ; int flipCount = 0 ; boolean flipped = false ; for ( int x = 0 ; x <= happy . length - spatWidth ; x ++ ) { if ( ! flipPoints . isEmpty ( ) && flipPoints . get ( 0 ) == x ) { flipPoints . remove ( 0 ) ; flipped = ! flipped ; } boolean current = happy [ x ] != flipped ; if ( ! current ) { flipped = ! flipped ; flipCount ++ ; flipPoints . add ( x + spatWidth ) ; } } for ( int x = happy . length - spatWidth + 1 ; x < happy . length ; x ++ ) { if ( ! flipPoints . isEmpty ( ) && flipPoints . get ( 0 ) == x ) { flipPoints . remove ( 0 ) ; flipped = ! flipped ; } if ( happy [ x ] == flipped ) { System . out . printf ( " Case ▁ # % d : ▁ IMPOSSIBLE % n " , t ) ; continue outer ; } } System . out . printf ( " Case ▁ # % d : ▁ % d % n " , t , flipCount ) ; } } }
(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 (object_creation_expression type: (type_identifier) arguments: (argument_list (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)))) (labeled_statement (identifier) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) 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: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (identifier)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier)))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier)))) (expression_statement (update_expression (identifier))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier)) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (identifier)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier)))) (continue_statement (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier)))))))))))