#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1, y1, x2, y2, area, minx, miny, maxx, maxy = 0;
  cin >> n;
  area = 0;
  minx = miny = 1000000;
  maxx = maxy = -1;
  while (n) {
    cin >> x1 >> y1 >> x2 >> y2;
    minx = min<int>(minx, x1);
    maxx = max<int>(maxx, x2);
    miny = min<int>(miny, y1);
    maxy = max<int>(maxy, y2);
    area += (x2 - x1) * (y2 - y1);
    n--;
  }
  if (maxx - minx != maxy - miny) {
    cout << "NO" << endl;
  } else {
    if (area != (maxx - minx) * (maxy - miny)) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
