#include #include #include #include #include #include #include using namespace std; using uint = unsigned int; using ll = long long; #define CIN( LL , A ) LL A; cin >> A #define GETLINE( A ) string A; getline( cin , A ) #define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) int main() { CIN( ll , N ); ll C[10][10] = {}; C[2][8] = 1; C[3][9] = 2; C[7][9] = 3; ll x; ll y; for( ll i = 0 ; i < N ; i++ ){ cin >> x >> y; ll& c = C[x][y]; cin >> x >> y; if( c != 0 ){ C[x][y] = c; c = 0; } } string answer; if( C[5][8] == 1 && C[4][8] == 2 && C[6][8] == 3 ){ answer = "YES"; } else { answer = "NO"; } cout << answer << endl; return 0; }