#include using namespace std; constexpr int n = 10; int main() { int q; cin >> q; vector> v(n, vector(n, 0)); v[2][8] = 1; v[3][9] = 2; v[7][9] = 3; while (q--) { int a, b, c, d; cin >> a >> b >> c >> d; swap(v[a][b], v[c][d]); } if (v[5][8] == 1 and v[4][8] == 2 and v[6][8] == 3) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }