#include using namespace std; typedef pair P; struct Node { P p; int id; bool operator<(const Node& n) const { return id < n.id; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; map > m; for (int i = 0; i < n; i++) { int r0, r1, c0, c1; cin >> r0 >> c0 >> r1 >> c1; P p1(r0, c0), p2(r1, c1); m[p1].push_back(i); m[p2].push_back(i); } vector a[5]; for (auto p : m) { for (int i : p.second) { a[p.second.size()].push_back((Node){p.first, i}); } } bool ans_flag = true; set

t; vector used(n, false); for (int i = 1; i <= 4; i++) { for (Node node : a[i]) { if (used[node.id]) continue; if (t.find(node.p) != t.end()) { ans_flag = false; break; } else { t.insert(node.p); used[node.id] = true; } } if (!ans_flag) break; } cout << (ans_flag ? "YES" : "NO") << endl; return 0; }