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