#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, minx = 31400, miny = 31400, maxx = 0, maxy = 0, sk, sp = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    sp += (x1 - x2) * (y1 - y2);
    if (minx > x1) minx = x1;
    if (miny > y1) miny = y1;
    if (maxx < x2) maxx = x2;
    if (maxy < y2) maxy = y2;
  }
  sk = (minx - maxx) * (miny - maxy);
  if (sk == sp && (minx - maxx) == (miny - maxy))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
