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