#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; pair a = { 2, 8 }, b = { 3, 9 }, c = { 7, 9 }; while (n--) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (a == make_pair(x1, y1)) a = { x2, y2 }; if (b == make_pair(x1, y1)) b = { x2, y2 }; if (c == make_pair(x1, y1)) c = { x2, y2 }; } bool ok = true; ok &= (a == make_pair(5, 8)); ok &= (b == make_pair(4, 8)); ok &= (c == make_pair(6, 8)); cout << (ok ? "YES" : "NO") << endl; return 0; }