#include #include using namespace std; int main(void) { int n, x1, y1, x2, y2; cin >> n; vector > abc = { {2,8},{3,9},{7,9} }; for (int i = 0; i < n; ++i) { cin >> x1 >> y1 >> x2 >> y2; pair a = { x1,y1 }, b = { x2,y2 }; for (int j = 0; j < 3; ++j) { if (abc[j] == a) abc[j] = b; } } pair a = { 5,8 }, b = { 4,8 }, c = { 6,8 }; if (abc[0] == a && abc[1] == b && abc[2] == c) cout << "YES" << endl; else cout << "NO" << endl; return 0; }