#include #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define FORR(i,a,b) for (int i=(a);i>=(b);i--) #define pb push_back using namespace std; typedef long long ll; typedef pair pii; typedef pair ti; typedef vector vi; typedef set si; const int inf = 1e9; const int mod = 1e9+7; vector sat[100][2][2]; vector li[10201]; main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; FOR(i, 0, n){ int a, b; FOR(j, 0, 2){ cin >> a >> b; a = a * 101 + b; li[a].pb(pii(i, j)); } FOR(j, 0, 2){ FOR(k, 0, 2){ sat[i][j][k].pb(ti(pii(i, 1-j), 1-k)); } } } FOR(i, 0, 10201){ FOR(j, 0, li[i].size()){ int f, s; f = li[i][j].first; s = li[i][j].second; FOR(k, 0, li[i].size()){ if(j==k)continue; int _f, _s; _f = li[i][k].first; _s = li[i][k].second; sat[f][s][1].pb(ti(pii(_f, _s), 0)); } } } set y; queue q; ti bad, tmp; vector tmpv; FOR(i, 0, n){ bool ok = false; FOR(j, 0, 2){ bool z = false; y.clear(); while(!q.empty())q.pop(); q.push(ti(pii(i, j), 1)); bad = ti(pii(i, j), 0); while(!q.empty()){ tmp = q.front(); q.pop(); y.insert(tmp); if(tmp == bad){ z = true; break; } tmpv = sat[tmp.first.first][tmp.first.second][tmp.second]; for(vector::iterator itr = tmpv.begin(); itr != tmpv.end(); itr++){ if(y.find(*itr) == y.end()){ q.push(*itr); } } } if(!z)ok = true; } if(!ok){ cout << "NO" <