#include <bits/stdc++.h>
using namespace std;
int nt;
int maxX, minX, maxY, minY;
int totalarea;
int area(int x1, int y1, int x2, int y2) { return (x2 - x1) * (y2 - y1); }
int main() {
  int a, b, c, d;
  cin >> nt;
  minX = minY = 32000;
  maxX = maxY = 0;
  totalarea = 0;
  for (int i = 0; i < nt; i++) {
    cin >> a >> b >> c >> d;
    totalarea += area(a, b, c, d);
    if (a < minX) minX = a;
    if (b < minY) minY = b;
    if (c > maxX) maxX = c;
    if (d > maxY) maxY = d;
  }
  if (area(minX, minY, maxX, maxY) == totalarea &&
      (maxX - minX) == (maxY - minY))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
