#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, k;
  while (cin >> n) {
    long xl = (1 << 30), yl = (1 << 30), ym = -(1 << 30), xm = -(1 << 30), x1,
         y1, x2, y2, s = 0;
    for (__typeof(n) i = 0; i < (n); i++) {
      cin >> x1 >> y1 >> x2 >> y2;
      xl = min(xl, x1);
      xm = max(xm, x2);
      yl = min(yl, y1);
      ym = max(ym, y2);
      s += (x2 - x1) * (y2 - y1);
    }
    if (s == (xm - xl) * (ym - yl) && (xm - xl) == (ym - yl))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
