#include <bits/stdc++.h>
using namespace std;
class Obj {
 public:
  int ind, loc;
  bool st;
  Obj(int a, int b, bool c) {
    ind = a;
    loc = b;
    st = c;
  }
  bool operator<(const Obj &o) const { return loc < o.loc; }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  vector<Obj> li[2];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      int a, b;
      cin >> a >> b;
      a *= 2;
      b *= 2;
      b++;
      li[j].push_back(Obj(i, a, true));
      li[j].push_back(Obj(i, b, false));
    }
  }
  for (int j = 0; j < 2; j++) {
    sort(li[j].begin(), li[j].end());
  }
  long long h[n];
  long long mod = 1000003;
  long long ans[2][n];
  bool ok = true;
  for (int z = 0; z < 4 && ok; z++) {
    for (int i = 0; i < n; i++) {
      h[i] = (rand() * (RAND_MAX + 1) + rand()) % mod;
      h[i] = (h[i] + 1) % mod;
    }
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < n; i++) {
        ans[j][i] = 0LL;
      }
    }
    long long endsum = 0LL;
    long long startsum = 0LL;
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < li[j].size(); i++) {
        if (li[j][i].st) {
          startsum += h[li[j][i].ind];
          ans[j][li[j][i].ind] -= endsum;
        } else {
          endsum += h[li[j][i].ind];
          ans[j][li[j][i].ind] += startsum;
        }
      }
    }
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < n; i++) {
        ans[j][i] %= mod;
        if (ans[j][i] < 0) {
          ans[j][i] += mod;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      ok = (ok && (ans[0][i] == ans[1][i]));
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
}
