static int Maze ( int matrix [ ] [ ] ) {
  Queue < pair > q = new LinkedList < > ( ) ;
  q . add ( new pair ( 0 , 0 ) ) ;
  int count = 0 ;
  while ( ! q . isEmpty ( ) ) {
    pair p = q . peek ( ) ;
    q . remove ( ) ;
    if ( p . first == n - 1 && p . second == m - 1 ) count ++ ;
    if ( p . first + 1 < n && matrix [ p . first + 1 ] [ p . second ] == 1 ) {
      q . add ( new pair ( p . first + 1 , p . second ) ) ;
    }
    if ( p . second + 1 < m && matrix [ p . first ] [ p . second + 1 ] == 1 ) {
      q . add ( new pair ( p . first , p . second + 1 ) ) ;
    }
  }
  return count ;
}

static int Maze ( int matrix [ ] [ ] ) { Queue < pair > q = new LinkedList < > ( ) ; q . add ( new pair ( 0 , 0 ) ) ; int count = 0 ; while ( ! q . isEmpty ( ) ) { pair p = q . peek ( ) ; q . remove ( ) ; if ( p . first == n - 1 && p . second == m - 1 ) count ++ ; if ( p . first + 1 < n && matrix [ p . first + 1 ] [ p . second ] == 1 ) { q . add ( new pair ( p . first + 1 , p . second ) ) ; } if ( p . second + 1 < m && matrix [ p . first ] [ p . second + 1 ] == 1 ) { q . add ( new pair ( p . first , p . second + 1 ) ) ; } } return count ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions))) body: (block (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)) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (local_variable_declaration type: (type_identifier) 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))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)) right: (identifier)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) index: (field_access object: (identifier) field: (identifier))) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)) (field_access object: (identifier) field: (identifier))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)) right: (identifier)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (field_access object: (identifier) field: (identifier))) index: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)) (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))))))))))) (return_statement (identifier))))