#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
struct Rec {
  int xl, yl, xr, yr;
  void Log() { fprintf(stderr, "%d %d %d %d\n", xl, yl, xr, yr); }
};
vector<Rec> total;
bool cmp0(const Rec &a, const Rec &b) {
  if (a.xl == b.xl) return a.xr > b.xr;
  return a.xl < b.xl;
}
bool cmp1(const Rec &a, const Rec &b) {
  if (a.xr == b.xr) return a.xl < b.xl;
  return a.xr > b.xr;
}
bool cmp2(const Rec &a, const Rec &b) {
  if (a.yl == b.yl) return a.yr > b.yr;
  return a.yl < b.yl;
}
bool cmp3(const Rec &a, const Rec &b) {
  if (a.yr == b.yr) return a.yl < b.yl;
  return a.yr > b.yr;
}
void input() {
  scanf(" %d", &n);
  for (int i = 0; i < n; ++i) {
    int a, b, c, d;
    scanf(" %d%d%d%d", &a, &b, &c, &d);
    total.push_back({a, b, c, d});
  }
}
bool check(vector<Rec> seq) {
  if (seq.size() == 1) return true;
  vector<Rec> ss[4];
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < seq.size(); ++j) ss[i].push_back(seq[j]);
  sort(ss[0].begin(), ss[0].end(), cmp0);
  sort(ss[1].begin(), ss[1].end(), cmp1);
  sort(ss[2].begin(), ss[2].end(), cmp2);
  sort(ss[3].begin(), ss[3].end(), cmp3);
  int cnt[4] = {0, 0, 0, 0};
  int last[4] = {ss[0][0].xr, ss[1][0].xl, ss[2][0].yr, ss[3][0].yl};
  for (int j = 1; j < seq.size(); ++j) {
    if (last[0] <= ss[0][j].xl) {
      if (j <= ss[0].size() - j) cnt[0] = j;
    }
    last[0] = max(last[0], ss[0][j].xr);
    if (last[1] >= ss[1][j].xr) {
      if (j <= ss[1].size() - j) cnt[1] = j;
    }
    last[1] = min(last[1], ss[1][j].xl);
    if (last[2] <= ss[2][j].yl) {
      if (j <= ss[2].size() - j) cnt[2] = j;
    }
    last[2] = max(last[2], ss[2][j].yr);
    if (last[3] >= ss[3][j].yr) {
      if (j <= ss[3].size() - j) cnt[3] = j;
    }
    last[3] = min(last[3], ss[3][j].yl);
  }
  int cntm = cnt[0], whe = 0;
  for (int i = 0; i < 4; ++i) {
    if (cntm < cnt[i]) {
      cntm = cnt[i];
      whe = i;
    }
  }
  if (cntm > 0) {
    vector<Rec> tmp;
    bool left = false, right = false;
    for (int i = 0; i < cntm; ++i) tmp.push_back(ss[whe][i]);
    left = check(tmp);
    tmp.clear();
    for (int i = cntm; i < ss[whe].size(); ++i) tmp.push_back(ss[whe][i]);
    right = check(tmp);
    return left && right;
  }
  return false;
}
int main() {
  input();
  bool isOk = check(total);
  if (isOk)
    puts("YES");
  else
    puts("NO");
  return 0;
}
