#include using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); typedef long long ll; // Welcome to my source code! template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int n; cin >> n; pair abc[3] = { make_pair(2, 8), make_pair(3, 9), make_pair(7, 9) }; int x[2], y[2]; while (n--) { cin >> x[0] >> y[0] >> x[1] >> y[1]; for (int i = 0; i < 3; i++) { if (abc[i] == make_pair(x[0], y[0])) { abc[i] = make_pair(x[1], y[1]); break; } } } pair t[3] = { make_pair(5, 8), make_pair(4, 8), make_pair(6, 8) }; if (abc[0] == t[0] && abc[1] == t[1] && abc[2] == t[2]) cout << "YES" << endl; else cout << "NO" << endl; }