#include <bits/stdc++.h>
int main(void) {
  int n = int();
  std ::cin >> n;
  int minX, minY, maxX, maxY;
  std ::cin >> minX >> minY >> maxX >> maxY;
  int sum = (maxX - minX) * (maxY - minY);
  for (int i = 1; i < n; ++i) {
    int x1, y1, x2, y2;
    std ::cin >> x1 >> y1 >> x2 >> y2;
    sum += (x2 - x1) * (y2 - y1);
    if (x1 < minX) minX = x1;
    if (x2 > maxX) maxX = x2;
    if (y1 < minY) minY = y1;
    if (y2 > maxY) maxY = y2;
  }
  if (maxY - minY == maxX - minX && (maxX - minX) * (maxY - minY) == sum)
    std ::cout << "YES" << std ::endl;
  else
    std ::cout << "NO" << std ::endl;
  return 0;
}
