#include #include using namespace std; typedef pair P; int n; P p[10][10]; int main(void) { cin >> n; for(int i = 1; i <= 9; i++){ for(int j = 1; j <= 9; j++){ p[i][j] = make_pair(i, j); } } int sx, sy, tx, ty; for(int i = 0; i < n; i++){ cin >> sx >> sy >> tx >> ty; swap(p[tx][ty], p[sx][sy]); } if(p[5][8] == make_pair(2, 8) && p[4][8] == make_pair(3, 9) && p[6][8] == make_pair(7, 9)) cout << "YES" << endl; else cout << "NO" << endl; return 0; }