#include int ri() { int n; assert(scanf("%d", &n) == 1); return n; } int main () { int board[10][10]; int cnt = 0; int a = -1, b = -1, c = -1; for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 9; j++) { if (j == 1 || j == 3 || j == 7 || j == 9 || (j == 2 && (i == 2 || i == 8)) || (j == 8 && (i == 2 || i == 8))) { board[i][j] = cnt++; } else board[i][j] = -1; if (i == 2 && j == 8) a = board[i][j]; if (i == 3 && j == 9) b = board[i][j]; if (i == 7 && j == 9) c = board[i][j]; } } assert(a != -1); assert(b != -1); assert(c != -1); int n = ri(); for (int i = 0; i < n; i++) { int x1 = ri(); int y1 = ri(); int x2 = ri(); int y2 = ri(); assert(board[x1][y1] != -1); assert(board[x2][y2] == -1); board[x2][y2] = board[x1][y1]; board[x1][y1] = -1; } std::cout << (board[5][8] == a && board[4][8] == b && board[6][8] == c ? "YES" : "NO") << std::endl; return 0; }