#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1, y1, x2, y2;
  int minX, maxX, minY, maxY;
  long long sum = 0, area = 0, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    a = (long long)x2 - x1;
    b = (long long)y2 - y1;
    sum += a * b;
    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);
    }
  }
  a = (long long)maxX - minX;
  b = (long long)maxY - minY;
  if (a != b) {
    printf("NO\n");
    return 0;
  }
  area = a * b;
  if (sum == area)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
