#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x1, x2, y1, y2, xmin, xmax, ymin, ymax;
  cin >> x1 >> y1 >> x2 >> y2;
  xmin = x1;
  xmax = x2;
  ymin = y1;
  ymax = y2;
  int total = (x2 - x1) * (y2 - y1);
  for (int a = 1; a < n; ++a) {
    cin >> x1 >> y1 >> x2 >> y2;
    xmin = min(x1, xmin);
    xmax = max(x2, xmax);
    ymin = min(y1, ymin);
    ymax = max(y2, ymax);
    total += (x2 - x1) * (y2 - y1);
  }
  if (ymax - ymin == xmax - xmin and (xmax - xmin) * (xmax - xmin) == total)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  cin >> n;
}
