#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long ML = 4e18;
bool check(vector<vector<int>>& a) {
  multiset<int> s, e;
  for (int i = (0); i < (a.size()); ++i) {
    if (a[i][1] == 1) {
      if (!s.empty()) {
        int maxS = *s.rbegin(), minE = *e.begin();
        if (a[i][3] < maxS || a[i][2] > minE) return false;
      }
      s.insert(a[i][2]);
      e.insert(a[i][3]);
    } else {
      s.erase(s.find(a[i][2]));
      e.erase(e.find(a[i][3]));
    }
  }
  return true;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(4)), b, c;
  for (int i = (0); i < (n); ++i) {
    cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
    b.push_back(vector<int>{a[i][0], 1, a[i][2], a[i][3]});
    b.push_back(vector<int>{a[i][1] + 1, 0, a[i][2], a[i][3]});
    c.push_back(vector<int>{a[i][2], 1, a[i][0], a[i][1]});
    c.push_back(vector<int>{a[i][3] + 1, 0, a[i][0], a[i][1]});
  }
  sort((b).begin(), (b).end());
  sort((c).begin(), (c).end());
  if (!check(b) || !check(c))
    cout << "NO\n";
  else
    cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
