public static void main ( String [ ] args ) throws IOException {
  BufferedReader in = new BufferedReader ( new FileReader ( "/Users/chao/Downloads/B-large.in" ) ) ;
  FileWriter out = new FileWriter ( "/Users/chao/Desktop/B-large.txt" ) ;
  String s = in . readLine ( ) ;
  int m = Integer . parseInt ( s ) ;
  for ( int cases = 1 ;
  cases <= m ;
  cases ++ ) {
    String [ ] ss = in . readLine ( ) . split ( " " ) ;
    int B = Integer . parseInt ( ss [ 0 ] ) ;
    long M = Long . parseLong ( ss [ 1 ] ) ;
    out . write ( "Case #" + cases + ": " ) ;
    int n = B ;
    long max = pow ( B - 2 ) ;
    if ( max >= M ) {
      out . write ( "POSSIBLE\n" ) ;
      int [ ] [ ] map = new int [ n ] [ n ] ;
      for ( int i = 1 ;
      i < n ;
      i ++ ) {
        for ( int j = i + 1 ;
        j < n ;
        j ++ ) {
          map [ i ] [ j ] = 1 ;
        }
      }
      for ( int k = 1 ;
      k < n ;
      k ++ ) {
        if ( k != n - 1 ) max = max / 2 ;
        if ( max <= M ) {
          M -= max ;
          map [ 0 ] [ k ] = 1 ;
        }
      }
      for ( int i = 0 ;
      i < n ;
      i ++ ) {
        for ( int j = 0 ;
        j < n ;
        j ++ ) {
          out . write ( "" + map [ i ] [ j ] ) ;
        }
        out . write ( "\n" ) ;
      }
    }
    else {
      out . write ( "IMPOSSIBLE\n" ) ;
    }
  }
  in . close ( ) ;
  out . flush ( ) ;
  out . close ( ) ;
}

public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new FileReader ( " / Users / chao / Downloads / B - large . in " ) ) ; FileWriter out = new FileWriter ( " / Users / chao / Desktop / B - large . txt " ) ; String s = in . readLine ( ) ; int m = Integer . parseInt ( s ) ; for ( int cases = 1 ; cases <= m ; cases ++ ) { String [ ] ss = in . readLine ( ) . split ( " ▁ " ) ; int B = Integer . parseInt ( ss [ 0 ] ) ; long M = Long . parseLong ( ss [ 1 ] ) ; out . write ( " Case ▁ # " + cases + " : ▁ " ) ; int n = B ; long max = pow ( B - 2 ) ; if ( max >= M ) { out . write ( " POSSIBLE \n " ) ; int [ ] [ ] map = new int [ n ] [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { map [ i ] [ j ] = 1 ; } } for ( int k = 1 ; k < n ; k ++ ) { if ( k != n - 1 ) max = max / 2 ; if ( max <= M ) { M -= max ; map [ 0 ] [ k ] = 1 ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { out . write ( " " + map [ i ] [ j ] ) ; } out . write ( " \n " ) ; } } else { out . write ( " IMPOSSIBLE \n " ) ; } } in . close ( ) ; out . flush ( ) ; out . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (type_identifier) 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 (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: (type_identifier) 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 (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) dimensions: (dimensions_expr (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 (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (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: (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 (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (identifier)) right: (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal))))))) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal)))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))