#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int N;
  scanf("%d", &N);
  long long vol = 0;
  int x1, x2, y1, y2, maxx = 0, maxy = 0, minx = 1000000, miny = 1000000;
  for (int i = 0; i < (N); i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    vol += (long long)(x2 - x1) * (y2 - y1);
    maxx = max(x2, maxx);
    maxy = max(y2, maxy);
    minx = min(x1, minx);
    miny = min(y1, miny);
  }
  if (maxx - minx == maxy - miny &&
      (long long)(maxx - minx) * (maxy - miny) == vol)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
