#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d, sx = 1e9, sy = 1e9, tx, ty, cnt;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    cnt += (c - a) * (d - b);
    sx = min(sx, a);
    sy = min(sy, b);
    tx = max(tx, c);
    ty = max(ty, d);
  }
  if (cnt == (tx - sx) * (ty - sy) && tx - sx == ty - sy)
    printf("YES\n");
  else
    printf("NO\n");
}
