#include #include void solve() { std::vector> ps{{2, 8}, {3, 9}, {7, 9}}, qs{{5, 8}, {4, 8}, {6, 8}}; int n; std::cin >> n; while (n--) { std::pair p, q; std::cin >> p.first >> p.second >> q.first >> q.second; for (int i = 0; i < 3; ++i) { if (ps[i] == p) ps[i] = q; } } std::cout << (ps == qs ? "YES" : "NO") << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }