#include <bits/stdc++.h>
using namespace std;
const long long LLINF = 1LL << 61;
const int INF = 1e9;
const double EPS = 1e-9;
int main() {
  long long s = 0;
  int n;
  cin >> n;
  int minx = INF, miny = INF, maxx = -INF, maxy = -INF;
  for (int i = 0, _n = (int)(n); i < _n; ++i) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    minx = min(minx, x1);
    maxx = max(maxx, x2);
    miny = min(miny, y1);
    maxy = max(maxy, y2);
    s += 1LL * (x2 - x1) * (y2 - y1);
  }
  long long ns = 1LL * (maxx - minx) * (maxy - miny);
  printf(ns == s && maxx - minx == maxy - miny ? "YES" : "NO");
  puts("");
  return 0;
}
