#include int a[100][100]; int main() { int N; std::cin >> N; for (int i = 1; i <= 9; ++i) { for (int j = 1; j <= 9; ++j) { a[i][j] = 0; } } a[2][8] = 1; a[3][9] = 2; a[7][9] = 3; for (int i = 0; i < N; ++i) { int x0, y0, x1, y1; std::cin >> x0 >> y0 >> x1 >> y1; if (a[x0][y0] == 0) continue; a[x1][y1] = a[x0][y0]; a[x0][y0] = 0; } if ((a[5][8] = 1) && (a[4][8] == 2) && (a[6][8] == 3)) { std::cout << "YES" << std::endl; } else { std::cout << "NO" << std::endl; } }