#include using namespace std; int main(){ // 1. 入力情報取得. int N; scanf("%d", &N); pair a = {2, 8}, b = {3, 9}, c = {7, 9}; for(int i = 0; i < N; i++){ int xb, yb, xa, ya; scanf("%d %d %d %d", &xb, &yb, &xa, &ya); // 座標更新(駒A). if(xb == a.first && yb == a.second){ a.first = xa; a.second = ya; continue; } // 座標更新(駒B). if(xb == b.first && yb == b.second){ b.first = xa; b.second = ya; continue; } // 座標更新(駒C). if(xb == c.first && yb == c.second){ c.first = xa; c.second = ya; continue; } } // 2. 移動後をチェック. bool ans = true; // 駒A. if(a.first != 5 || a.second != 8) ans = false; // 駒B. if(b.first != 4 || b.second != 8) ans = false; // 駒C. if(c.first != 6 || c.second != 8) ans = false; // 3. 後処理. if(ans) printf("%s\n", "YES"); else printf("%s\n", "NO"); return 0; }