#include <bits/stdc++.h>
using namespace std;
int main() {
  int minx, maxx, miny, maxy, sumofarea = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (i == 0) {
      minx = x1;
      maxx = x2;
      miny = y1;
      maxy = y2;
    } else {
      minx = min(minx, x1);
      maxx = max(maxx, x2);
      miny = min(miny, y1);
      maxy = max(maxy, y2);
    }
    sumofarea += ((x2 - x1) * (y2 - y1));
  }
  int final_square_area = (maxx - minx) * (maxy - miny);
  int lengthofside1 = maxx - minx;
  int lengthofside2 = maxy - miny;
  if (sumofarea == final_square_area && (lengthofside1 == lengthofside2)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
