#include <bits/stdc++.h>
int main() {
  int n, i, t, x1, y1, x2, y2, max_x = -1, max_y = -1, min_x = 31401,
                               min_y = 31401, size;
  scanf("%d", &n);
  size = 0;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 < min_x) min_x = x1;
    if (x2 > max_x) max_x = x2;
    if (y1 < min_y) min_y = y1;
    if (y2 > max_y) max_y = y2;
    size += (x2 - x1) * (y2 - y1);
  }
  t = (max_x - min_x) * (max_y - min_y);
  if ((max_x - min_x) == (max_y - min_y) && t == size)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
