#include using namespace std; #define rep(i,a,b) for(int i=a;i E[20101]; //----------------------------------------------------------------- bool done[20101]; bool red[20101]; bool ans = true; void dfs(int cur) { done[cur] = true; for (int to : E[cur]) if (!done[to]) { if (!red[cur]) red[cur] = true; else { if (red[to]) { ans = false; return; } red[to] = true; } } for (int to : E[cur]) if (!done[to]) dfs(to); } //----------------------------------------------------------------- int main() { cin >> N; rep(i, 0, N) { int r0, c0, r1, c1; scanf("%d %d %d %d", &r0, &c0, &r1, &c1); r0--; c0--; r1--; c1--; int a = r0 * 150 + c0; int b = r1 * 150 + c1; E[a].push_back(b); E[b].push_back(a); } rep(i, 0, 20101) if(!done[i] && E[i].size() == 1) dfs(i); rep(i, 0, 20101) if (!done[i] && 1 < E[i].size()) dfs(i); if (ans) printf("YES\n"); else printf("NO\n"); }