#include <bits/stdc++.h>
using namespace std;
typedef struct pt {
  int x, y;
} point;
int main() {
  int i, j, k, l, n, area = 0;
  point a, b, lb, rt;
  lb.x = 31401;
  lb.y = 31401;
  rt.x = -1;
  rt.y = -1;
  cin >> n;
  while (n--) {
    cin >> a.x >> a.y >> b.x >> b.y;
    lb.x = min(lb.x, a.x);
    lb.y = min(lb.y, a.y);
    rt.x = max(rt.x, b.x);
    rt.y = max(rt.y, b.y);
    area += (b.y - a.y) * (b.x - a.x);
  }
  i = rt.y - lb.y;
  j = rt.x - lb.x;
  if (i == j && area == i * j)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
