#include #include #include #include using namespace std; using P = pair; int dr[4] = {1, 0, -1, 0}, dc[4] = {0, 1, 0, -1}; const int NUM = 114514; vector graph[NUM]; int color[NUM]; bool dfs(int v, int c, int prev) { color[v] = c; for (int to : graph[v]) { if (to == prev) continue; if (color[to] < 0) { if (!dfs(to, 1, v)) return false; } else if (color[to] == c) { return false; } } return true; } int main() { int n; cin >> n; memset(color, -1, sizeof(color)); int id = 0; map dict; for (int i = 0; i < n; i++) { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; P p1 = make_pair(r1, c1), p2 = make_pair(r2, c2); int id1, id2; if (dict.find(p1) == dict.end()) { dict[p1] = id; id++; } if (dict.find(p2) == dict.end()) { dict[p2] = id; id++; } id1 = dict[p1]; id2 = dict[p2]; graph[id1].push_back(id2); graph[id2].push_back(id1); } for (int v = 0; v < id; v++) { if (color[v] == -1) { if (!dfs(v, 0, -1)) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }