#include <bits/stdc++.h>
using namespace std;
int main() {
  long long minx = 1000000000, maxx = -1000000000, miny = 1000000000,
            maxy = -1000000000;
  long long pole = 0;
  int n;
  cin >> n;
  int x1, x2, y1, y2;
  while (n--) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (minx > x1) minx = x1;
    if (maxx < x2) maxx = x2;
    if (miny > y1) miny = y1;
    if (maxy < y2) maxy = y2;
    pole += (x2 - x1) * (y2 - y1);
  }
  if (maxx - minx == maxy - miny && (maxx - minx) * (maxy - miny) == pole)
    cout << "YES\n";
  else
    cout << "NO\n";
}
