#include <bits/stdc++.h>
using namespace std;
int a[32000];
int main() {
  int n;
  scanf("%d", &n);
  int maxx = 0;
  int maxy = 0;
  int minx = 1000000000, miny = 1000000000;
  int i, j;
  int x1, x2, y1, y2;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x2 > maxx) maxx = x2;
    if (x1 < minx) minx = x1;
    if (y2 > maxy) maxy = y2;
    if (y1 < miny) miny = y1;
    for (j = y1; j < y2; j++) {
      a[j] += x2 - x1;
    }
  }
  bool no = 0;
  if (maxx - minx != maxy - miny) {
    no = 1;
  } else {
    for (i = miny; i < maxy; i++) {
      if (a[i] != maxx - minx) {
        no = 1;
        break;
      }
    }
  }
  if (no)
    printf("NO\n");
  else
    printf("YES\n");
}
