public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int runs = sc . nextInt ( ) ;
  while ( runs -- > 0 ) {
    int size = sc . nextInt ( ) ;
    boolean optimal = true ;
    int [ ] arr = new int [ size + 1 ] ;
    int out = 0 ;
    boolean add = false ;
    int [ ] dex = new int [ 2 ] ;
    for ( int i = 1 ;
    i < size + 1 ;
    i ++ ) {
      arr [ i ] = 1 ;
    }
    for ( int i = 0 ;
    i < size ;
    i ++ ) {
      int len = sc . nextInt ( ) ;
      boolean fill = false ;
      for ( int j = 0 ;
      j < len ;
      j ++ ) {
        int num = sc . nextInt ( ) ;
        if ( ! fill ) {
          if ( arr [ num ] == 1 ) {
            out ++ ;
            arr [ num ] -- ;
            fill = true ;
          }
        }
      }
      if ( ! fill && add == false ) {
        dex [ 0 ] = i + 1 ;
        add = true ;
      }
    }
    if ( add ) {
      for ( int j = 1 ;
      j < size + 1 ;
      j ++ ) {
        if ( arr [ j ] == 1 ) {
          arr [ j ] = 0 ;
          out ++ ;
          optimal = false ;
          dex [ 1 ] = j ;
          break ;
        }
      }
    }
    if ( optimal ) System . out . println ( "OPTIMAL" ) ;
    else {
      System . out . println ( "IMPROVE" ) ;
      System . out . println ( dex [ 0 ] + " " + dex [ 1 ] ) ;
    }
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int size = sc . nextInt ( ) ; boolean optimal = true ; int [ ] arr = new int [ size + 1 ] ; int out = 0 ; boolean add = false ; int [ ] dex = new int [ 2 ] ; for ( int i = 1 ; i < size + 1 ; i ++ ) { arr [ i ] = 1 ; } for ( int i = 0 ; i < size ; i ++ ) { int len = sc . nextInt ( ) ; boolean fill = false ; for ( int j = 0 ; j < len ; j ++ ) { int num = sc . nextInt ( ) ; if ( ! fill ) { if ( arr [ num ] == 1 ) { out ++ ; arr [ num ] -- ; fill = true ; } } } if ( ! fill && add == false ) { dex [ 0 ] = i + 1 ; add = true ; } } if ( add ) { for ( int j = 1 ; j < size + 1 ; j ++ ) { if ( arr [ j ] == 1 ) { arr [ j ] = 0 ; out ++ ; optimal = false ; dex [ 1 ] = j ; break ; } } } if ( optimal ) System . out . println ( " OPTIMAL " ) ; else { System . out . println ( " IMPROVE " ) ; System . out . println ( dex [ 0 ] + " ▁ " + dex [ 1 ] ) ; } } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) 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: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (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 (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (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 (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: (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (true))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (identifier)) right: (binary_expression left: (identifier) right: (false)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (true))))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (false))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))) (break_statement))))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (string_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))))))))))))