#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios_base::sync_with_stdio(false);
  int n, x[10], y[10], nx[10], ny[10];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> nx[i] >> ny[i];
  int mnx = 1000000, mny = 1000000, mxx = 0, mxy = 0;
  for (int i = 0; i < n; i++) {
    mnx = min(mnx, x[i]);
    mny = min(mny, y[i]);
    mxx = max(mxx, nx[i]);
    mxy = max(mxy, ny[i]);
  }
  long long area = (mxx - mnx) * (mxy - mny);
  long long realarea = 0;
  for (int i = 0; i < n; i++) {
    realarea += (nx[i] - x[i]) * (ny[i] - y[i]);
  }
  if (mxx - mnx == mxy - mny && area == realarea)
    printf("YES");
  else
    printf("NO");
}
