#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long p = 0;
  int a = 2123456789, b = -2123456789, c = 2123456789, d = -2123456789;
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    p += (x2 - x1) * (y2 - y1);
    a = min(a, x1);
    b = max(b, x2);
    c = min(c, y1);
    d = max(d, y2);
  }
  if (b - a == d - c && (long long)(b - a) * (d - c) == p)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
