#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1, y1, x2, y2;
  int sumArea = 0, maxX = 0, maxY = 0;
  int minY = 999999999, minX = 999999999;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    sumArea += abs(x1 - x2) * abs(y1 - y2);
    maxX = max(maxX, max(x1, x2));
    maxY = max(maxY, max(y1, y2));
    minX = min(minX, min(x1, x2));
    minY = min(minY, min(y1, y2));
  }
  if ((maxX - minX) - (maxY - minY) == 0 &&
      (maxX - minX) * (maxY - minY) == sumArea)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
