#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:20000000")
string problem_name = "a";
void init() { freopen((problem_name + ".in").c_str(), "rt", stdin); }
int n;
long long xmin = 100000, xmax = -100000, ymin = 100000, ymax = -100000;
int main() {
  long long sq = 0;
  cin >> n;
  while (n--) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    xmin = min(xmin, x1);
    xmin = min(xmin, x2);
    xmax = max(xmax, x2);
    ymax = max(ymax, y2);
    ymin = min(ymin, y1);
    sq += (x2 - x1) * (long long)(y2 - y1);
  }
  if (ymax - ymin != xmax - xmin) {
    cout << "NO";
    return 0;
  }
  if ((ymax - ymin) * (xmax - xmin) != sq) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
