#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int NMAX = 412345;
struct prednaska {
  int time[2][2];
  ll nahodny;
  ll h[2];
};
prednaska pr[NMAX];
pair<prednaska*, bool> s[NMAX];
int n;
void makeH(int in) {
  for (int i = 0; i < n; i++) {
    s[2 * i] = make_pair(pr + i, 0);
    s[2 * i + 1] = make_pair(pr + i, 1);
  }
  sort(s, s + 2 * n,
       [&](pair<prednaska*, bool> a, pair<prednaska*, bool> b) -> bool {
         if (a.first->time[in][a.second] == b.first->time[in][b.second])
           return a.second < b.second;
         return (a.first->time[in][a.second] < b.first->time[in][b.second]);
       });
  ll hes = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (s[i].second)
      hes += s[i].first->nahodny;
    else
      s[i].first->h[in] = hes;
  }
  hes = 0;
  for (int i = 2 * n - 1; i >= 0; i--) {
    if (!s[i].second)
      hes += s[i].first->nahodny;
    else
      s[i].first->h[in] += hes;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d%d%d", pr[i].time[0] + 0, pr[i].time[0] + 1, pr[i].time[1] + 0,
          pr[i].time[1] + 1);
  srand(417829);
  for (int ioi = 0; ioi < 10; ioi++) {
    for (int i = 0; i < n; i++)
      pr[i].nahodny = rand() + (ll(rand()) << 20) + (ll(rand()) << 40);
    makeH(0);
    makeH(1);
    for (int i = 0; i < n; i++) {
      if (pr[i].h[0] != pr[i].h[1]) {
        {
          printf("NO\n");
          return 0;
        }
      }
    }
  }
  printf("YES\n");
  return 0;
}
