#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int main() { ios_base::sync_with_stdio(0); cin.tie(0); map, char> pos; pos[{2, 8}] = 'A'; pos[{3, 9}] = 'B'; pos[{7, 9}] = 'C'; int n; cin >> n; REP (i, n) { int a, b, c, d; cin >> a >> b >> c >> d; char target = pos[{a, b}]; pos[{c, d}] = target; pos.erase({a, b}); } if (pos[{5, 8}] == 'A' && pos[{4, 8}] == 'B' && pos[{6, 8}] == 'C') cout << "YES" << endl; else cout << "NO" << endl; return 0; }