#include using namespace std; int main() { int N; cin >> N; vector> grid(10, vector(10, 0)); grid[2][8] = 1; grid[3][9] = 2; grid[7][9] = 3; for (int i = 0; i < N; i++) { int x, y, z, w; cin >> x >> y >> z >> w; if (grid[x][y] > 0) { grid[z][w] = grid[x][y]; grid[x][y] = 0; } } if (grid[5][8] == 1 && grid[4][8] == 2 && grid[6][8] == 3) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }