public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  int T = in . nextInt ( ) ;
  for ( int cas = 1 ;
  cas <= T ;
  cas ++ ) {
    int n = in . nextInt ( ) ;
    BigInteger P = new BigInteger ( in . next ( ) ) ;
    BigInteger last_pos = B ( 2 ) . pow ( n ) . subtract ( P ) ;
    int min_ones = 0 ;
    for ( min_ones = 0 ;
    min_ones <= n ;
    min_ones ++ ) {
      BigInteger val = B ( 0 ) ;
      for ( int i = 0 ;
      i < min_ones ;
      i ++ ) val = A ( val , B ( 2 ) . pow ( n - 1 - i ) ) ;
      if ( val . compareTo ( last_pos ) >= 0 ) break ;
    }
    BigInteger last_win = B ( 2 ) . pow ( n ) . subtract ( B ( 2 ) . pow ( min_ones ) ) ;
    int min_zeroes = 0 ;
    for ( min_zeroes = 0 ;
    min_zeroes <= n ;
    min_zeroes ++ ) {
      BigInteger val = B ( 2 ) . pow ( n ) . subtract ( B ( 1 ) ) ;
      for ( int i = 0 ;
      i < min_zeroes ;
      i ++ ) val = val . subtract ( B ( 2 ) . pow ( n - 1 - i ) ) ;
      if ( val . compareTo ( last_pos ) < 0 ) break ;
    }
    BigInteger last_guarantee = B ( 2 ) . pow ( min_zeroes ) . subtract ( B ( 2 ) ) ;
    if ( last_pos . equals ( B ( 0 ) ) ) last_guarantee = B ( 2 ) . pow ( n ) . subtract ( B ( 1 ) ) ;
    System . out . printf ( "Case #%d: %s %s\n" , cas , last_guarantee , last_win ) ;
  }
}

public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int cas = 1 ; cas <= T ; cas ++ ) { int n = in . nextInt ( ) ; BigInteger P = new BigInteger ( in . next ( ) ) ; BigInteger last_pos = B ( 2 ) . pow ( n ) . subtract ( P ) ; int min_ones = 0 ; for ( min_ones = 0 ; min_ones <= n ; min_ones ++ ) { BigInteger val = B ( 0 ) ; for ( int i = 0 ; i < min_ones ; i ++ ) val = A ( val , B ( 2 ) . pow ( n - 1 - i ) ) ; if ( val . compareTo ( last_pos ) >= 0 ) break ; } BigInteger last_win = B ( 2 ) . pow ( n ) . subtract ( B ( 2 ) . pow ( min_ones ) ) ; int min_zeroes = 0 ; for ( min_zeroes = 0 ; min_zeroes <= n ; min_zeroes ++ ) { BigInteger val = B ( 2 ) . pow ( n ) . subtract ( B ( 1 ) ) ; for ( int i = 0 ; i < min_zeroes ; i ++ ) val = val . subtract ( B ( 2 ) . pow ( n - 1 - i ) ) ; if ( val . compareTo ( last_pos ) < 0 ) break ; } BigInteger last_guarantee = B ( 2 ) . pow ( min_zeroes ) . subtract ( B ( 2 ) ) ; if ( last_pos . equals ( B ( 0 ) ) ) last_guarantee = B ( 2 ) . pow ( n ) . subtract ( B ( 1 ) ) ; System . out . printf ( " Case ▁ # % d : ▁ % s ▁ % s \n " , cas , last_guarantee , last_win ) ; } }
(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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) 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 (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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (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 name: (identifier) arguments: (argument_list (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: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal))) consequence: (break_statement)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (assignment_expression left: (identifier) right: (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: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (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: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal))) consequence: (break_statement)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal)))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal))) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier) (identifier) (identifier))))))))