#include <bits/stdc++.h>
using namespace std;
int main() {
  int area = 0, xy1[2], xy2[2], xmax = 0, ymax = 0, xmin = 32000, ymin = 32000,
      n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d%d", &xy1[0], &xy1[1], &xy2[0], &xy2[1]);
    area += (xy2[0] - xy1[0]) * (xy2[1] - xy1[1]);
    if (xmax < xy2[0]) xmax = xy2[0];
    if (ymax < xy2[1]) ymax = xy2[1];
    if (xmin > xy1[0]) xmin = xy1[0];
    if (ymin > xy1[1]) ymin = xy1[1];
  }
  if (xmax - xmin != ymax - ymin || (ymax - ymin) * (xmax - xmin) != area)
    printf("NO");
  else
    printf("YES");
  return 0;
}
