#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 100005;
int n;
pii a[4][N];
int nxt[4][N], pre[4][N];
void del(int p) {
  for (int i = 0; i < 4; i++) {
    int a = pre[i][p], b = nxt[i][p];
    nxt[i][a] = b;
    pre[i][b] = a;
  }
}
bool dfs(vector<int> &left) {
  if (left.size() <= 1) return 1;
  for (int i = 0; i < 4; i++) {
    sort(left.begin(), left.end(),
         [&](int x, int y) { return a[i][x] < a[i][y]; });
    int p = 0;
    for (auto &j : left) {
      nxt[i][p] = j;
      pre[i][j] = p;
      p = j;
    }
    nxt[i][p] = 0;
  }
  int num = left.size();
  while (num > 1) {
    bool fi = 0;
    int head[4], target[4];
    for (int i = 0; i < 4; i++)
      head[i] = nxt[i][0], target[i] = a[i][head[i]].second;
    for (int i = 1; i < num && !fi; i++)
      for (int j = 0; j < 4; j++) {
        head[j] = nxt[j][head[j]];
        if (a[j][head[j]].first >= target[j]) {
          vector<int> s;
          for (int k = nxt[j][0]; k != head[j]; k = nxt[j][k]) s.push_back(k);
          for (auto &k : s) del(k);
          for (int k = 0; k < 4; k++) head[k] = nxt[k][0];
          if (!dfs(s)) return 0;
          num -= i;
          for (int k = 0; k < 4; k++) nxt[k][0] = head[k];
          fi = 1;
          break;
        } else
          target[j] = max(target[j], a[j][head[j]].second);
      }
    if (!fi) return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int t1, t2, t3, t4;
    cin >> t1 >> t2 >> t3 >> t4;
    a[0][i] = pii(t1, t3);
    a[1][i] = pii(t2, t4);
    a[2][i] = pii(-t3, -t1);
    a[3][i] = pii(-t4, -t2);
  }
  vector<int> v;
  for (int i = 1; i <= n; i++) v.push_back(i);
  cout << (dfs(v) ? "YES" : "NO");
  return 0;
}
