#include using namespace std; typedef pair P; typedef pair P2; int main() { int n; cin >> n; vector xy(n); for (int i = 0; i < n; ++i) { int x, y; cin >> x >> y; P one = P(x, y); cin >> x >> y; P two = P(x, y); xy[i] = P2(one, two); } int cx = 2, cy = 8; for (int i = 0; i < n; ++i) { P2 cur = xy[i]; if (cur.first.first == cx && cur.first.second == cy) { cx = cur.second.first; cy = cur.second.second; } } if (cx != 5 || cy != 8) { puts("NO"); return 0; } cx = 3; cy = 9; for (int i = 0; i < n; ++i) { P2 cur = xy[i]; if (cur.first.first == cx && cur.first.second == cy) { cx = cur.second.first; cy = cur.second.second; } } if (cx != 4 || cy != 8) { puts("NO"); return 0; } cx = 7; cy = 9; for (int i = 0; i < n; ++i) { P2 cur = xy[i]; if (cur.first.first == cx && cur.first.second == cy) { cx = cur.second.first; cy = cur.second.second; } } if (cx != 6 || cy != 8) { puts("NO"); return 0; } puts("YES"); return 0; }