#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   struct par {     int x, t;     bool operator!=(par k) { return x != k.x || t != k.t; }   } p[N], p2[N];   int flag, n, sa[N], ea[N], sb[N], eb[N], _[N], _lans, _rans, key1[N], key2[N];   bool cmp(par x, par y) {     int kx = x.t == 1 ? sa[x.x] : ea[x.x];     int ky = y.t == 1 ? sa[y.x] : ea[y.x];     return kx * 2 + (1 ^ x.t) == ky * 2 + (1 ^ y.t)                ? x.x < y.x                : kx * 2 + (1 ^ x.t) < ky * 2 + (1 ^ y.t);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       scanf( %d%d%d%d , sa + i, ea + i, sb + i, eb + i);     for (int i = 1; i <= n; i++) _[i] = rand();     for (int i = 1; i <= 2 * n; i++) p[i] = (par){(i - 1) / 2 + 1, i & 1};     sort(p + 1, p + 1 + n + n, cmp);     _lans = _rans = 0;     for (int i = 1; i <= n; i++) _lans ^= _[i];     for (int i = 1; i <= 2 * n; i++) {       int x = p[i].x, t = p[i].t;       if (t) {         _lans ^= _[x];         key1[x] ^= _rans;       } else {         _rans ^= _[x];         key1[x] ^= _lans;       }     }     memcpy(p2, p, sizeof(p));     for (int i = 1; i <= n; i++) swap(sa[i], sb[i]), swap(ea[i], eb[i]);     for (int i = 1; i <= 2 * n; i++) p[i] = (par){(i - 1) / 2 + 1, i & 1};     sort(p + 1, p + 1 + n + n, cmp);     _lans = _rans = 0;     for (int i = 1; i <= n; i++) _lans ^= _[i];     for (int i = 1; i <= 2 * n; i++) {       int x = p[i].x, t = p[i].t;       if (t) {         _lans ^= _[x];         key2[x] ^= _rans;       } else {         _rans ^= _[x];         key2[x] ^= _lans;       }     }     for (int i = 1; i <= n; i++)       if (key1[i] != key2[i]) flag = 1;     puts(flag ?  NO  :  YES );     return 0;   }   