#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60);
int main() {
  int n;
  cin >> n;
  long long x1, y1, x2, y2, mnx = INF, mxx = -INF, mny = INF, mxy = -INF,
                            sum = 0;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> x1 >> y1 >> x2 >> y2;
    mnx = min(mnx, x1);
    mxx = max(mxx, x2);
    mny = min(mny, y1);
    mxy = max(mxy, y2);
    sum += (x2 - x1) * (y2 - y1);
  }
  if (mxx - mnx == mxy - mny && (mxx - mnx) * (mxy - mny) == sum) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
