#include <bits/stdc++.h>
using namespace std;
int n;
int x0, x1, y00, y11;
int minx, maxx, miny, maxy;
int main() {
  scanf("%d", &n);
  long long s = 0;
  minx = miny = 1e9;
  maxx = maxy = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d%d", &x0, &y00, &x1, &y11);
    minx = min(x0, minx);
    maxx = max(x1, maxx);
    miny = min(y00, miny);
    maxy = max(y11, maxy);
    s += (x1 - x0) * 1ll * (y11 - y00);
  }
  long long lenx = maxx - minx, leny = maxy - miny;
  if (lenx != leny || lenx * leny != s)
    printf("NO\n");
  else
    printf("YES\n");
}
