#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, n, u, v, llx = 10000000, lly = 10000000, rrx = 0, rry = 0;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> u >> v;
    llx = min(llx, min(x, u));
    lly = min(lly, min(y, v));
    rrx = max(rrx, max(x, u));
    rry = max(rry, max(y, v));
    sum += (u - x) * (v - y);
  }
  if ((rrx - llx) * (rry - lly) == sum && rrx - llx == rry - lly)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
