#include <bits/stdc++.h>
using namespace std;
void solve(istream &in, ostream &out) {
  int n;
  in >> n;
  int xl = 31401, xh = -1, yl = 31401, yh = -1;
  long long a = 0;
  for (int i = 0; i < n; ++i) {
    int x1, y1, x2, y2;
    in >> x1 >> y1 >> x2 >> y2;
    xl = min(xl, x1);
    yl = min(yl, y1);
    xh = max(xh, x2);
    yh = max(yh, y2);
    a += (x2 - x1) * (y2 - y1);
  }
  int lx = xh - xl, ly = yh - yl;
  if (lx != ly || lx * ly != a) {
    out << "NO" << endl;
  } else {
    out << "YES" << endl;
  }
}
int main() {
  solve(cin, cout);
  return 0;
}
