#include #define rep(i, ss, ee) for (int i = ss; i < ee; ++i) using namespace std; using P = pair; //(2,8),(3,9),(7,9) //(5,8),(4,8),(6,8) void solve() { int N; cin >> N; vector

s{{2, 8}, {3, 9}, {7, 9}}; vector

e{{5, 8}, {4, 8}, {6, 8}}; P p, q; rep(i, 0, N) { cin >> p.first >> p.second >> q.first >> q.second; rep(j, 0, 3) { if (s[j] == p) s[j] = q; } } cout << ((s[0] == e[0] && s[1] == e[1] && s[2] == e[2]) ? "YES" : "NO") << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); getchar(); }