#include <bits/stdc++.h>
using namespace std;
int main() {
  int s = 0, x = -1, y = -1, xx = 100000, yy = 100000, a, e, d, f, r;
  scanf("%d", &a);
  for (int i = 0; i < a; i++) {
    scanf("%d%d%d%d", &e, &d, &f, &r);
    if (xx > e) xx = e;
    if (yy > d) yy = d;
    if (x < f) x = f;
    if (y < r) y = r;
    s += (f - e) * (r - d);
  }
  if ((x - xx) * (y - yy) == s && x - xx == y - yy)
    printf("YES");
  else
    printf("NO");
}
