public static void main ( String [ ] args ) throws Exception {
  BufferedReader br = new BufferedReader ( new FileReader ( new File ( "in" ) ) ) ;
  BufferedWriter bw = new BufferedWriter ( new FileWriter ( new File ( "out" ) ) ) ;
  StringTokenizer st ;
  int T = Integer . parseInt ( br . readLine ( ) ) ;
  for ( int cn = 1 ;
  cn <= T ;
  cn ++ ) {
    st = new StringTokenizer ( br . readLine ( ) ) ;
    int N = Integer . parseInt ( st . nextToken ( ) ) ;
    int M = Integer . parseInt ( st . nextToken ( ) ) ;
    int arr [ ] [ ] = new int [ N ] [ M ] ;
    for ( int i = 0 ;
    i < N ;
    i ++ ) {
      st = new StringTokenizer ( br . readLine ( ) ) ;
      for ( int j = 0 ;
      j < M ;
      j ++ ) {
        arr [ i ] [ j ] = Integer . parseInt ( st . nextToken ( ) ) ;
      }
    }
    boolean okay = true ;
    for ( int i = 0 ;
    i < N ;
    i ++ ) {
      for ( int j = 0 ;
      j < M ;
      j ++ ) {
        int h = arr [ i ] [ j ] ;
        boolean ok1 = true ;
        for ( int k = 0 ;
        k < N ;
        k ++ ) ok1 &= arr [ k ] [ j ] <= h ;
        boolean ok2 = true ;
        for ( int k = 0 ;
        k < M ;
        k ++ ) ok2 &= arr [ i ] [ k ] <= h ;
        if ( ! ( ok1 || ok2 ) ) okay = false ;
      }
    }
    if ( okay ) bw . append ( "Case #" + cn + ": YES\n" ) ;
    else bw . append ( "Case #" + cn + ": NO\n" ) ;
  }
  bw . flush ( ) ;
}

public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new FileReader ( new File ( " in " ) ) ) ; BufferedWriter bw = new BufferedWriter ( new FileWriter ( new File ( " out " ) ) ) ; StringTokenizer st ; int T = Integer . parseInt ( br . readLine ( ) ) ; for ( int cn = 1 ; cn <= T ; cn ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; int M = Integer . parseInt ( st . nextToken ( ) ) ; int arr [ ] [ ] = new int [ N ] [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; for ( int j = 0 ; j < M ; j ++ ) { arr [ i ] [ j ] = Integer . parseInt ( st . nextToken ( ) ) ; } } boolean okay = true ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int h = arr [ i ] [ j ] ; boolean ok1 = true ; for ( int k = 0 ; k < N ; k ++ ) ok1 &= arr [ k ] [ j ] <= h ; boolean ok2 = true ; for ( int k = 0 ; k < M ; k ++ ) ok2 &= arr [ i ] [ k ] <= h ; if ( ! ( ok1 || ok2 ) ) okay = false ; } } if ( okay ) bw . append ( " Case ▁ # " + cn + " : ▁ YES \n " ) ; else bw . append ( " Case ▁ # " + cn + " : ▁ NO \n " ) ; } bw . flush ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (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 (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 (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (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 (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (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)))))) (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)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) dimensions: (dimensions_expr (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 (assignment_expression left: (identifier) right: (object_creation_expression type: (type_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: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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 (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: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (identifier))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (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: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (identifier))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (false)))))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal))))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))