public static void main ( String ... args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int tests = sc . nextInt ( ) ;
  for ( int test = 1 ;
  test <= tests ;
  ++ test ) {
    int n = sc . nextInt ( ) ;
    int m = sc . nextInt ( ) ;
    int [ ] [ ] lawn = new int [ n ] [ m ] ;
    int [ ] rowMaxes = new int [ n ] ;
    int [ ] colMaxes = new int [ m ] ;
    boolean possible = true ;
    for ( int i = 0 ;
    i < n ;
    ++ i ) {
      for ( int j = 0 ;
      j < m ;
      ++ j ) {
        int a = sc . nextInt ( ) ;
        lawn [ i ] [ j ] = a ;
        rowMaxes [ i ] = Math . max ( a , rowMaxes [ i ] ) ;
        colMaxes [ j ] = Math . max ( a , colMaxes [ j ] ) ;
        if ( a > 100 ) {
          possible = false ;
        }
      }
    }
    for ( int i = 0 ;
    i < n & possible ;
    ++ i ) {
      for ( int j = 0 ;
      j < m & possible ;
      ++ j ) {
        if ( lawn [ i ] [ j ] < rowMaxes [ i ] && lawn [ i ] [ j ] < colMaxes [ j ] ) {
          possible = false ;
        }
      }
    }
    System . out . println ( "Case #" + test + ": " + ( possible ? "YES" : "NO" ) ) ;
  }
}

public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int tests = sc . nextInt ( ) ; for ( int test = 1 ; test <= tests ; ++ test ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] lawn = new int [ n ] [ m ] ; int [ ] rowMaxes = new int [ n ] ; int [ ] colMaxes = new int [ m ] ; boolean possible = true ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { int a = sc . nextInt ( ) ; lawn [ i ] [ j ] = a ; rowMaxes [ i ] = Math . max ( a , rowMaxes [ i ] ) ; colMaxes [ j ] = Math . max ( a , colMaxes [ j ] ) ; if ( a > 100 ) { possible = false ; } } } for ( int i = 0 ; i < n & possible ; ++ i ) { for ( int j = 0 ; j < m & possible ; ++ j ) { if ( lawn [ i ] [ j ] < rowMaxes [ i ] && lawn [ i ] [ j ] < colMaxes [ j ] ) { possible = false ; } } } System . out . println ( " Case ▁ # " + test + " : ▁ " + ( possible ? " YES " : " NO " ) ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (spread_parameter (type_identifier) (variable_declarator 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)))) (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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 (identifier)) dimensions: (dimensions_expr (identifier))))) (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 (identifier))))) (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 (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: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (binary_expression left: (identifier) right: (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: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (parenthesized_expression (ternary_expression condition: (identifier) consequence: (string_literal) alternative: (string_literal)))))))))))