private static long [ ] dfs ( Node node ) {
  node . visited = true ;
  long [ ] count = new long [ ] {
    1 , 1 };
    for ( Node n : node . neighbors ) {
      if ( ! n . visited ) {
        long [ ] c = dfs ( n ) ;
        count [ 0 ] *= ( c [ 0 ] + c [ 1 ] ) % M ;
        count [ 0 ] %= M ;
        count [ 1 ] *= c [ 0 ] ;
        count [ 1 ] %= M ;
      }
    }
    return count ;
  }
  
private static long [ ] dfs ( Node node ) { node . visited = true ; long [ ] count = new long [ ] { 1 , 1 } ; for ( Node n : node . neighbors ) { if ( ! n . visited ) { long [ ] c = dfs ( n ) ; count [ 0 ] *= ( c [ 0 ] + c [ 1 ] ) % M ; count [ 0 ] %= M ; count [ 1 ] *= c [ 0 ] ; count [ 1 ] %= M ; } } return count ; }
(method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (true))) (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) value: (array_initializer (decimal_integer_literal) (decimal_integer_literal))))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (field_access object: (identifier) field: (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (field_access object: (identifier) field: (identifier)))) consequence: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal)))) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))))))) (return_statement (identifier))))