private static String getResult ( Scanner s ) {
  int numNodes = s . nextInt ( ) ;
  List < GraphNode > nodes = new ArrayList < GraphNode > ( numNodes ) ;
  for ( int i = 0 ;
  i < numNodes ;
  i ++ ) {
    nodes . add ( new GraphNode ( ) ) ;
  }
  for ( int i = 0 ;
  i < numNodes ;
  i ++ ) {
    int numChildren = s . nextInt ( ) ;
    for ( int j = 0 ;
    j < numChildren ;
    j ++ ) {
      int child = s . nextInt ( ) ;
      nodes . get ( child - 1 ) . childNodes . add ( nodes . get ( i ) ) ;
    }
  }
  for ( GraphNode node : nodes ) {
    if ( node . childNodes . size ( ) > 1 && node . hasDiamond ( ) ) {
      return "Yes" ;
    }
  }
  return "No" ;
}

private static String getResult ( Scanner s ) { int numNodes = s . nextInt ( ) ; List < GraphNode > nodes = new ArrayList < GraphNode > ( numNodes ) ; for ( int i = 0 ; i < numNodes ; i ++ ) { nodes . add ( new GraphNode ( ) ) ; } for ( int i = 0 ; i < numNodes ; i ++ ) { int numChildren = s . nextInt ( ) ; for ( int j = 0 ; j < numChildren ; j ++ ) { int child = s . nextInt ( ) ; nodes . get ( child - 1 ) . childNodes . add ( nodes . get ( i ) ) ; } } for ( GraphNode node : nodes ) { if ( node . childNodes . size ( ) > 1 && node . hasDiamond ( ) ) { return " Yes " ; } } return " No " ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (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: (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 (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 (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_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)))) (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)))) (expression_statement (method_invocation object: (field_access object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (return_statement (string_literal)))))) (return_statement (string_literal))))