#include <bits/stdc++.h>
using namespace std;
stringstream sss;
int main() {
  int n;
  cin >> n;
  int topRightX = 0;
  int topRightY = 0;
  int lowestLeftX = (int)1e9;
  int lowestLeftY = (int)1e9;
  int rectArea = 0;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    rectArea += ((x2 - x1) * (y2 - y1));
    topRightX = max(x2, topRightX);
    topRightY = max(y2, topRightY);
    lowestLeftX = min(x1, lowestLeftX);
    lowestLeftY = min(y1, lowestLeftY);
  }
  if ((topRightX - lowestLeftX) == (topRightY - lowestLeftY) &&
      rectArea == (topRightX - lowestLeftX) * (topRightY - lowestLeftY)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
