#include <bits/stdc++.h>
int main() {
  int n = 0;
  double s = 0, xm = 0, ym = 0, xl = 31400, yl = 31400;
  scanf("%d", &n);
  while (n--) {
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    s = (y2 - y1) * (x2 - x1) + s;
    if (x1 <= xl) xl = x1;
    if (y1 <= yl) yl = y1;
    if (x2 >= xm) xm = x2;
    if (y2 >= ym) ym = y2;
  }
  if ((xm - xl) == (ym - yl) && s == (xm - xl) * (ym - yl)) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
