#include #define REP(i, n) for(int i = 0; i < n; i++) #define REPR(i, n) for(int i = n; i >= 0; i--) #define FOR(i, m, n) for(int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector> from(n, vector(2)); vector> to(n, vector(2)); vector> start{{2,8}, {3, 9}, {7, 9}}; vector> goal{{5,8}, {4, 8}, {6, 8}}; vector current{0, 0}; REP(i, n) { cin >> from[i][0] >> from[i][1]; cin >> to[i][0] >> to[i][1]; } string ans = "YES"; REP(i, 3) { current = start[i]; REP(j, n) { if(current == from[j])current = to[j]; } if(current != goal[i]) { ans = "NO"; break; } } cout << ans << endl; }