#include using namespace std; int main(void) { int n; cin >> n; pair a(28, 0), b(39, 0), c(79, 0); int x1, y1, x2, y2; int before, after; // 動かした駒の座標を整数に変換 for(int i = 0; i < n; i++) { cin >> x1 >> y1 >> x2 >> y2; before = x1 * 10 + y1; after = x2 * 10 + y2; if (before == a.first && a.second == 0 || before == a.second) a.second = after; else if (before == b.first && b.second == 0 || before == b.second) b.second = after; else if (before == c.first && c.second == 0 || before == c.second) c.second = after; } if (a.first == 28 && a.second == 58 && b.first == 39 && b.second == 48 && c.first == 79 && c.second == 68) cout << "YES"; else cout << "NO"; return 0; }