#include <bits/stdc++.h>
using namespace std;
long long int n, m, i, j, k, l, a[1000009], b[1000009], p[1000009], ans, cn, t,
    x, y, z, mx, mn, s, my, dx, dy;
char c[1000009], d[1000009], ch;
int main() {
  while (scanf("%I64dd", &n) != EOF) {
    ans = 0;
    mx = my = 0;
    dx = dy = 999999999;
    for (i = 0; i < n; i++) {
      scanf("%I64d %I64d %I64d %I64d", &x, &y, &z, &s);
      ans += ((z - x) * (s - y));
      mx = max(mx, z);
      my = max(my, s);
      dx = min(dx, x);
      dy = min(dy, y);
    }
    if ((ans == (mx - dx) * (my - dy)) && (mx - dx == my - dy)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
