#include <bits/stdc++.h>
using namespace std;
int n;
int sum = 0, ans;
int maxx = 0, maxy = 0, minx = 100000, miny = 100000;
int x11, y11, x22, y22;
int main() {
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &x11, &y11);
    maxx = max(maxx, x11);
    minx = min(minx, x11);
    maxy = max(maxy, y11);
    miny = min(miny, y11);
    scanf("%d%d", &x22, &y22);
    maxx = max(maxx, x22);
    minx = min(minx, x22);
    maxy = max(maxy, y22);
    miny = min(miny, y22);
    sum += abs((x22 - x11) * (y22 - y11));
  }
  ans = abs((maxx - minx) * (maxy - miny));
  if (sum == ans && (maxx - minx) == (maxy - miny))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
