#include #include #include #include #include using namespace std; int main() { int n; cin >> n; vector>X; X.reserve(2 * n); for (int i = 0; i < n; i++) { int r0, r1, c0, c1; cin >> r0 >> c0 >> r1 >> c1; X.push_back(make_pair(r0, c0)); X.push_back(make_pair(r1, c1)); } sort(X.begin(), X.end()); int cnt = 0; bool flag = true; for (int i = 1; i < 2 * n; i++) { if (X[i] == X[i - 1]) { cnt++; } else { if (cnt >= 2)flag = false; cnt = 0; } } if (cnt > 2)flag = false; if (flag)cout << "YES" << endl; else cout << "NO" << endl; return 0; }