#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  int minx = 100000, maxx = -100000;
  int miny = 100000, maxy = -100000;
  for (int i = 0; i < n; i++) {
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    sum += (x2 - x1) * (y2 - y1);
    minx = min(minx, x1);
    maxx = max(maxx, x2);
    miny = min(miny, y1);
    maxy = max(maxy, y2);
  }
  if (maxx - minx == maxy - miny && (maxx - minx) * (maxy - miny) == sum)
    puts("YES");
  else
    puts("NO");
  return 0;
}
