#include <bits/stdc++.h>
int main() {
  int n, i;
  scanf("%d\n", &n);
  int pov = 0;
  int xmin = 33000;
  int ymin = 33000;
  int xmax = 0;
  int ymax = 0;
  for (i = 0; i < n; i++) {
    int x1, x2, y1, y2;
    scanf("%d %d %d %d\n", &x1, &y1, &x2, &y2);
    if (x1 < xmin) xmin = x1;
    if (x2 > xmax) xmax = x2;
    if (y1 < ymin) ymin = y1;
    if (y2 > ymax) ymax = y2;
    pov += (x2 - x1) * (y2 - y1);
  }
  int raz = xmax - xmin;
  int razy = ymax - ymin;
  if (raz == razy && raz * razy == pov)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
