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