// includes {{{ #include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<map> #include<set> #include<tuple> #include<cmath> #include<random> #include<cassert> #include<bitset> #include<cstdlib> // #include<deque> // #include<multiset> // #include<cstring> // #include<bits/stdc++.h> // }}} using namespace std; using ll = long long; int f[100][100]; #define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl; #define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl; #define YES(x) cout<<((x)?"YES":"NO")<<endl; #define Yes(x) cout<<((x)?"Yes":"No")<<endl; #define yes(x) cout<<((x)?"yes":"no")<<endl; int main() { std::ios::sync_with_stdio(false), std::cin.tie(0); int n; cin >> n; f[2][8] = 1; f[3][9] = 2; f[7][9] = 3; for(int i = 0; i < n; i++) { int x,y,z,w; cin >> x >> y >> z >> w; f[z][w] = f[x][y]; f[x][y] = 0; } YES(1 == f[5][8] and 2 == f[4][8] and 3 == f[6][8]); return 0; }