#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[100005][4];
set<long long> se;
map<long long, long long> mp;
pair<long long, long long> ve[400005][5];
pair<long long, long long> pe[400005][5];
long long prim(long long i) {
  for (long long j = 2; j * j <= i; j++) {
    if (i % j == 0) return 0;
  }
  return 1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<long long> prime;
  for (long long i = 2; i < 201; i++) {
    if (prim(i)) prime.push_back(i);
  }
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
    se.insert(a[i][0]);
    se.insert(a[i][1]);
    se.insert(a[i][2]);
    se.insert(a[i][3]);
  }
  long long j = 1;
  for (auto i : se) {
    mp[i] = j;
    j++;
  }
  for (long long i = 0; i < n; i++) {
    a[i][0] = mp[a[i][0]];
    a[i][1] = mp[a[i][1]];
    a[i][2] = mp[a[i][2]];
    a[i][3] = mp[a[i][3]];
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 5; j++) {
      ve[a[i][0]][j].first += i % prime[j];
      ve[a[i][2]][j].second += i % prime[j];
      pe[a[i][1]][j].first += i % prime[j];
      pe[a[i][3]][j].second += i % prime[j];
    }
  }
  for (long long i = 1; i < 400005; i++)
    for (long long j = 0; j < 5; j++) {
      ve[i][j].first += ve[i - 1][j].first;
      ve[i][j].second += ve[i - 1][j].second;
      pe[i][j].first += pe[i - 1][j].first;
      pe[i][j].second += pe[i - 1][j].second;
    }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 5; j++) {
      if (ve[a[i][1]][j].first - pe[a[i][0] - 1][j].first !=
          ve[a[i][3]][j].second - pe[a[i][2] - 1][j].second) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
