#include <bits/stdc++.h>
using namespace std;
int n, mx, t, h1, h2, h3, ans, k, mnx, mny, mxx, mxy;
map<int, int> mpx;
map<int, int> mpy;
int x1m[10], x2m[10], y1m[10], y2m[10];
bool v[100][100];
void rx(int x) { mpx[x] = 0; }
void ry(int y) { mpy[y] = 0; }
int del(map<int, int> mp) {
  map<int, int>::iterator i = mp.end();
  i--;
  return i->first - mp.begin()->first;
}
int main() {
  while (~scanf("%d", &n)) {
    mpx.clear();
    mpy.clear();
    for (h1 = 0; h1 < n; h1++) {
      scanf("%d%d %d%d", &x1m[h1], &y1m[h1], &x2m[h1], &y2m[h1]);
      rx(x1m[h1]);
      rx(x2m[h1]);
      ry(y1m[h1]);
      ry(y2m[h1]);
    }
    int w1, w2, hh1, hh2;
    mnx = mny = 0;
    h1 = 0;
    for (map<int, int>::iterator i = mpx.begin(); i != mpx.end(); i++)
      i->second = h1++;
    mxx = h1 - 1;
    h1 = 0;
    for (map<int, int>::iterator i = mpy.begin(); i != mpy.end(); i++) {
      i->second = h1++;
    }
    mxy = h1 - 1;
    if (del(mpx) != del(mpy)) {
      cout << "NO\n";
      continue;
    }
    memset(v, 0, sizeof(v));
    for (h1 = 0; h1 < n; h1++) {
      int x1 = min(mpx[x1m[h1]], mpx[x2m[h1]]),
          x2 = max(mpx[x1m[h1]], mpx[x2m[h1]]);
      int y1 = min(mpy[y1m[h1]], mpy[y2m[h1]]),
          y2 = max(mpy[y1m[h1]], mpy[y2m[h1]]);
      for (h2 = x1; h2 < x2; h2++)
        for (h3 = y1; h3 < y2; h3++) v[h2][h3] = 1;
    }
    {
      bool yes = 1;
      int x1 = mnx, x2 = mxx;
      int y1 = mny, y2 = mxy;
      for (h1 = x1; h1 < x2; h1++)
        for (h2 = y1; h2 < y2; h2++)
          if (!v[h1][h2]) yes = 0;
      cout << (yes ? "YES\n" : "NO\n");
    }
  }
}
