#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
int n, m, N, M, I, J;
int di[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dj[] = {0, 0, 1, -1, 1, -1, 1, -1};
bool val(const int& i, const int& j) {
  return i >= 0 && i < I && j >= 0 && j < J;
}
int comp(const double& a, const double& b) {
  if (fabs(a - b) < eps) return 0;
  return a < b ? -1 : 1;
}
int main() {
  map<int, int> mx, my;
  cin >> n;
  int xa[5], ya[5], xb[5], yb[5];
  int mnx = oo, mxx = -oo, mny = oo, mxy = -oo;
  for (int i = 0; i < (int)(n); i++) {
    cin >> xa[i] >> ya[i] >> xb[i] >> yb[i];
    mx[xa[i]];
    mx[xb[i]];
    my[ya[i]];
    my[yb[i]];
    mnx = min(mnx, xa[i]);
    mxx = max(mxx, xb[i]);
    mny = min(mny, ya[i]);
    mxy = max(mxy, yb[i]);
  }
  int cur = 0;
  for (__typeof(mx.begin()) it = mx.begin(); it != mx.end(); ++it)
    it->second = cur++;
  int xx = cur - 1;
  cur = 0;
  for (__typeof(my.begin()) it = my.begin(); it != my.end(); ++it)
    it->second = cur++;
  int yy = cur - 1;
  for (int i = 0; i < (int)(n); i++) {
    xa[i] = mx[xa[i]];
    xb[i] = mx[xb[i]];
    ya[i] = my[ya[i]];
    yb[i] = my[yb[i]];
  }
  int cc = 0;
  for (int i = 0; i < (int)(n); i++) cc += (xb[i] - xa[i]) * (yb[i] - ya[i]);
  if (xx * yy == cc && mxx - mnx == mxy - mny)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
