#include <bits/stdc++.h>
using namespace std;
struct Line {
  int x, y1, y2, z;
} a[20];
int n, z[40000], sum, ymin, ymax;
bool cmp(Line p, Line q) { return p.x < q.x; }
int main() {
  sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int xa, ya, xb, yb;
    scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
    if (i == 0) {
      ymin = ya;
      ymax = yb;
    } else {
      ymin = min(ymin, ya);
      ymax = max(ymax, yb);
    }
    a[i * 2].x = xa;
    a[i * 2].y1 = ya;
    a[i * 2].y2 = yb;
    a[i * 2].z = 1;
    a[i * 2 + 1].x = xb;
    a[i * 2 + 1].y1 = ya;
    a[i * 2 + 1].y2 = yb;
    a[i * 2 + 1].z = -1;
    sum += (xb - xa) * (yb - ya);
  }
  sort(a, a + n + n, cmp);
  bool flag = ((a[n * 2 - 1].x - a[0].x) * (a[n * 2 - 1].x - a[0].x) == sum);
  for (int i = 0; i < 2 * n; i++) {
    for (int j = a[i].y1; j < a[i].y2; j++) z[j] += a[i].z;
    if (flag)
      if (i < 2 * n - 1 && a[i].x < a[i + 1].x) {
        for (int j = ymin; j < ymax; j++)
          if (z[j] != 1) flag = false;
      }
  }
  if (flag)
    puts("YES");
  else
    puts("NO");
  return 0;
}
