#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const double pi = 3.1415926;
const long double eps = 1e-9;
const int N = (int)1e5 + 5;
const int INF = (int)1e9 + 7;
const double EPS = 0.001;
int main() {
  int n;
  cin >> n;
  int x1, y1, x2, y2, s1 = 0, s2 = 0;
  int mx = INF, my = INF, mxx = -1, mxy = -1;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    mx = min(mx, x1);
    my = min(my, y1);
    mxx = max(x2, mxx);
    mxy = max(y2, mxy);
    s1 += (x2 - x1) * (y2 - y1);
  }
  if ((mxx - mx) * (mxy - my) == s1 && (mxx - mx == mxy - my))
    cout << "YES";
  else
    cout << "NO";
}
