public static void main ( String args [ ] ) throws IOException {
  BufferedReader in = new BufferedReader ( new FileReader ( "A-small-attempt0.in" ) ) ;
  PrintWriter out = new PrintWriter ( new FileWriter ( "A-small.out" ) ) ;
  int T = Integer . parseInt ( in . readLine ( ) ) ;
  for ( int i = 0 ;
  i < T ;
  i ++ ) {
    boolean adj [ ] [ ] = new boolean [ 1005 ] [ 1005 ] ;
    int N ;
    String s = in . readLine ( ) ;
    StringTokenizer st = new StringTokenizer ( s ) ;
    N = Integer . parseInt ( st . nextToken ( ) ) ;
    for ( int r = 0 ;
    r < N ;
    r ++ ) {
      s = in . readLine ( ) ;
      st = new StringTokenizer ( s ) ;
      int M = Integer . parseInt ( st . nextToken ( ) ) ;
      for ( int c = 0 ;
      c < M ;
      c ++ ) {
        int d = Integer . parseInt ( st . nextToken ( ) ) - 1 ;
        adj [ r ] [ d ] = true ;
      }
    }
    boolean ans = false ;
    for ( int n = 0 ;
    n < N ;
    n ++ ) {
      LinkedList < Integer > q = new LinkedList < Integer > ( ) ;
      q . add ( n ) ;
      boolean v [ ] = new boolean [ N ] ;
      while ( ! q . isEmpty ( ) ) {
        int x = q . pollFirst ( ) ;
        if ( v [ x ] ) {
          ans = true ;
          break ;
        }
        v [ x ] = true ;
        for ( int m = 0 ;
        m < N ;
        m ++ ) {
          if ( adj [ x ] [ m ] ) {
            q . addFirst ( m ) ;
          }
        }
      }
    }
    out . println ( "Case #" + ( i + 1 ) + ": " + ( ans ? "Yes" : "No" ) ) ;
  }
  out . close ( ) ;
}

public static void main ( String args [ ] ) throws IOException { BufferedReader in = new BufferedReader ( new FileReader ( " A - small - attempt0 . in " ) ) ; PrintWriter out = new PrintWriter ( new FileWriter ( " A - small . out " ) ) ; int T = Integer . parseInt ( in . readLine ( ) ) ; for ( int i = 0 ; i < T ; i ++ ) { boolean adj [ ] [ ] = new boolean [ 1005 ] [ 1005 ] ; int N ; String s = in . readLine ( ) ; StringTokenizer st = new StringTokenizer ( s ) ; N = Integer . parseInt ( st . nextToken ( ) ) ; for ( int r = 0 ; r < N ; r ++ ) { s = in . readLine ( ) ; st = new StringTokenizer ( s ) ; int M = Integer . parseInt ( st . nextToken ( ) ) ; for ( int c = 0 ; c < M ; c ++ ) { int d = Integer . parseInt ( st . nextToken ( ) ) - 1 ; adj [ r ] [ d ] = true ; } } boolean ans = false ; for ( int n = 0 ; n < N ; n ++ ) { LinkedList < Integer > q = new LinkedList < Integer > ( ) ; q . add ( n ) ; boolean v [ ] = new boolean [ N ] ; while ( ! q . isEmpty ( ) ) { int x = q . pollFirst ( ) ; if ( v [ x ] ) { ans = true ; break ; } v [ x ] = true ; for ( int m = 0 ; m < N ; m ++ ) { if ( adj [ x ] [ m ] ) { q . addFirst ( m ) ; } } } } out . println ( " Case ▁ # " + ( i + 1 ) + " : ▁ " + ( ans ? " Yes " : " No " ) ) ; } out . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (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 (object_creation_expression type: (type_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 (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: (boolean_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (decimal_integer_literal)) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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 (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (true))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (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: (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)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (identifier))))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (array_access array: (identifier) index: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true))) (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 (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (string_literal)) right: (parenthesized_expression (ternary_expression condition: (identifier) consequence: (string_literal) alternative: (string_literal))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))