#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T, typename U>
ostream& operator<<(ostream& _s, pair<T, U> _t) {
  _s << "(" << _t.first << "," << _t.second << ")";
  return _s;
}
template <typename T, typename U>
istream& operator>>(istream& _s, pair<T, U>& _t) {
  _s >> _t.first >> _t.second;
  return _s;
}
template <typename T>
ostream& operator<<(ostream& _s, vector<T> _t) {
  for (int i = 0; i < (int)(_t.size()); i++) _s << (i ? " " : "") << _t[i];
  return _s;
}
template <typename T>
istream& operator>>(istream& _s, vector<T>& _t) {
  for (int i = 0; i < (int)(_t.size()); i++) _s >> _t[i];
  return _s;
}
template <typename T>
ostream& operator<<(ostream& _s, vector<vector<T>> _t) {
  for (int i = 0; i < (int)(_t.size()); i++) {
    _s << i << ": " << _t[i] << endl;
  }
  return _s;
}
int n;
bool isHappy(vector<pair<ll, ll>>& va, vector<pair<ll, ll>>& vb) {
  vector<vector<ll>> e;
  for (int i = 0; i < (int)(n); i++) {
    e.push_back({va[i].first, 0, i});
    e.push_back({va[i].second, 1, i});
  }
  sort(e.begin(), e.end());
  set<pair<ll, int>> frs, tos;
  for (auto& ev : e) {
    bool begin = ev[1] == 0;
    int i = ev[2];
    if (begin) {
      frs.insert({vb[i].first, i});
      tos.insert({vb[i].second, i});
      ll mnto = tos.begin()->first;
      ll mxfr = (--frs.end())->first;
      if (mnto < mxfr) {
        return false;
      }
    } else {
      frs.erase({vb[i].first, i});
      tos.erase({vb[i].second, i});
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  vector<pair<ll, ll>> va(n), vb(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> va[i] >> vb[i];
  }
  bool happy = isHappy(va, vb) && isHappy(vb, va);
  cout << (happy ? "YES" : "NO") << endl;
}
