public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  int n ;
  int x1 , y1 , x2 , y2 ;
  while ( in . hasNext ( ) ) {
    int maxx = - 1 , minx = 40000 , maxy = - 1 , miny = 40000 ;
    n = in . nextInt ( ) ;
    long ans1 , ans2 = 0 ;
    for ( int i = 0 ;
    i < n ;
    ++ i ) {
      x1 = in . nextInt ( ) ;
      y1 = in . nextInt ( ) ;
      x2 = in . nextInt ( ) ;
      y2 = in . nextInt ( ) ;
      maxx = Math . max ( x2 , maxx ) ;
      minx = Math . min ( x1 , minx ) ;
      maxy = Math . max ( y2 , maxy ) ;
      miny = Math . min ( y1 , miny ) ;
      ans2 += Math . abs ( x2 - x1 ) * Math . abs ( y2 - y1 ) ;
    }
    ans1 = Math . abs ( maxx - minx ) * Math . abs ( maxy - miny ) ;
    if ( maxx - minx != maxy - miny || ans1 != ans2 ) System . out . println ( "NO" ) ;
    else System . out . println ( "YES" ) ;
  }
  in . close ( ) ;
}

public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n ; int x1 , y1 , x2 , y2 ; while ( in . hasNext ( ) ) { int maxx = - 1 , minx = 40000 , maxy = - 1 , miny = 40000 ; n = in . nextInt ( ) ; long ans1 , ans2 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { x1 = in . nextInt ( ) ; y1 = in . nextInt ( ) ; x2 = in . nextInt ( ) ; y2 = in . nextInt ( ) ; maxx = Math . max ( x2 , maxx ) ; minx = Math . min ( x1 , minx ) ; maxy = Math . max ( y2 , maxy ) ; miny = Math . min ( y1 , miny ) ; ans2 += Math . abs ( x2 - x1 ) * Math . abs ( y2 - y1 ) ; } ans1 = Math . abs ( maxx - minx ) * Math . abs ( maxy - miny ) ; if ( maxx - minx != maxy - miny || ans1 != ans2 ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } in . close ( ) ; }
(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))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier) value: (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 (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))