#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
bool solve() {
  int n;
  if (scanf("%d", &n) < 1) return 0;
  long long S = 0;
  int x1, x2, y1, y2;
  assert(n > 0);
  for (int i = 0; i < n; ++i) {
    int cx1, cx2, cy1, cy2;
    scanf("%d%d%d%d", &cx1, &cy1, &cx2, &cy2);
    if (i == 0 || x1 > cx1) x1 = cx1;
    if (i == 0 || x2 < cx2) x2 = cx2;
    if (i == 0 || y1 > cy1) y1 = cy1;
    if (i == 0 || y2 < cy2) y2 = cy2;
    S += (cx2 - cx1) * (cy2 - cy1);
  }
  long long rS = (x2 - x1) * (y2 - y1);
  printf((rS == S && (x2 - x1) == (y2 - y1)) ? "YES\n" : "NO\n");
  return 1;
}
int main() {
  srand(rdtsc());
  while (1) {
    if (!solve()) break;
  }
  return 0;
}
