#include using namespace std; #define REP(i,a) for(int i = 0; i < (a); i++) #define ALL(a) (a).begin(),(a).end() typedef long long ll; typedef pair P; const int INF = 1e9; const int MOD = 1e9 + 7; signed main(){ int n; cin >> n; P a[3]; a[0] = P(2, 8), a[1] = P(3, 9), a[2] = P(7, 9); int x1,y1,x2,y2; REP(i,n){ cin >> x1 >> y1 >> x2 >> y2; REP(j,3){ if(x1 == a[j].first && y1 == a[j].second){ a[j].first = x2; a[j].second = y2; } } } if(a[0] == P(5, 8) && a[1] == P(4, 8) && a[2] == P(6, 8)){ cout << "YES" << endl; }else{ cout << "NO" << endl; } }