#include <bits/stdc++.h>
using ll = long long;
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  int n;
  std::cin >> n;
  int maxx = 0, maxy = 0, minx = 1e6, miny = 1e6;
  int area = 0;
  for (int i = 0; i < n; ++i) {
    int x1, x2, y1, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    maxx = std::max(maxx, x2);
    minx = std::min(x1, minx);
    maxy = std::max(y2, maxy);
    miny = std::min(miny, y1);
    area += (x2 - x1) * (y2 - y1);
  }
  int dx = maxx - minx;
  int dy = maxy - miny;
  if (dx == dy && (dx * dy == area))
    std::cout << "YES\n";
  else
    std::cout << "NO\n";
}
