#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000LL;
int main() {
  int n;
  scanf("%d", &n);
  long long minx = INF, maxx = -1, miny = INF, maxy = -1;
  long long tot = 0;
  for (int i = 0; i < (n); i++) {
    int x1, y1;
    scanf("%d%d", &x1, &y1);
    int x2, y2;
    scanf("%d%d", &x2, &y2);
    tot += (x2 - x1) * ((long long)y2 - y1);
    minx = min(minx, (long long)x1);
    maxx = max(maxx, (long long)x2);
    miny = min(miny, (long long)y1);
    maxy = max(maxy, (long long)y2);
  }
  puts(maxx - minx == maxy - miny && tot == (maxx - minx) * (maxy - miny)
           ? "YES"
           : "NO");
}
