#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int MAXN = 1000000 + 10;
int main() {
  int n = 0;
  scanf("%d", &n);
  int sum = 0;
  int maxX = -32000, maxY = -32000, minX = 32000, minY = 32000;
  while (n--) {
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    sum += (x2 - x1) * (y2 - y1);
    if (maxX < x2) maxX = x2;
    if (minX > x1) minX = x1;
    if (maxY < y2) maxY = y2;
    if (minY > y1) minY = y1;
  }
  if (sum == (maxX - minX) * (maxY - minY) && (maxX - minX) == (maxY - minY))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
