#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long minX = 100000, maxX = 0, minY = 100000, maxY = 0;
  long long area = 0;
  for (int i = 0; i < n; i++) {
    long long x0, x1, y0, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    minX = min(minX, x0);
    minY = min(minY, y0);
    maxX = max(maxX, x1);
    maxY = max(maxY, y1);
    area += (x1 - x0) * (y1 - y0);
  }
  cout << ((maxX - minX == maxY - minY && area == (maxX - minX) * (maxY - minY))
               ? "YES"
               : "NO")
       << endl;
}
