#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000005;
const long long SQRTN = 1003;
const long long LOGN = 22;
const double PI = acos(-1);
const long long INF = 1e16;
const long long MOD = 1000000007;
const long long FMOD = 998244353;
const double eps = 1e-9;
void solvethetestcase();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long testcase = 1; testcase < t + 1; testcase++) {
    solvethetestcase();
  }
}
long long n;
long long ar = 0;
void solvethetestcase() {
  cin >> n;
  long long mnx, mny, mxx, mxy;
  cin >> mnx >> mny >> mxx >> mxy;
  ar += (mxx - mnx) * (mxy - mny);
  for (long long i = 0; i < n - 1; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    ar += (c - a) * (d - b);
    mnx = min(mnx, a);
    mny = min(mny, b);
    mxx = max(mxx, c);
    mxy = max(mxy, d);
  }
  if ((mxy - mny) == (mxx - mnx) and (mxy - mny) * (mxx - mnx) == ar)
    cout << "YES\n";
  else
    cout << "NO\n";
}
