#include <bits/stdc++.h>
using namespace std;
bool flag;
struct point {
  int x, y;
};
int main() {
  int x1, y1, x2, y2, x_max, y_max, x_min, y_min;
  int n;
  long long int area;
  scanf("%d", &n);
  x_max = -1.0;
  y_max = -1.0;
  x_min = 31402.0;
  y_min = 31402.0;
  area = 0;
  while (n--) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x2 > x_max) {
      x_max = x2;
    }
    if (y2 > y_max) {
      y_max = y2;
    }
    if (x1 < x_min) {
      x_min = x1;
    }
    if (y1 < y_min) {
      y_min = y1;
    }
    area += (x2 - x1) * (y2 - y1);
  }
  if (x_max - x_min == y_max - y_min) {
    if ((long long int)(x_max - x_min) * (y_max - y_min) == area) {
      printf("YES");
    } else
      printf("NO");
  } else
    printf("NO");
  return 0;
}
