#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; pii pos[10][10]; int FROM[6] = { 2,8 ,3,9,7,9 }; int TO[6] = { 5,8,4,8,6,8 }; void solve() { rep(i, 10)rep(j, 10)pos[i][j] = mp(i, j); int N; cin >> N; rep(i, N) { int x, y, X, Y; cin >> x >> y >> X >> Y; pos[X][Y] = pos[x][y]; pos[x][y] = mp(-1, -1); } rep(i, 3) { if (pos[TO[i * 2]][TO[i * 2 + 1]] != mp(FROM[i * 2], FROM[i * 2 + 1])) { cout << "NO" << endl; return; } } cout << "YES" << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }