#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define loop(i,a,b) for(int i=a;i pii; typedef vector vi; typedef vector vvi; typedef vector vp; typedef vector vvp; typedef vector vs; typedef vector vd; typedef vector vvd; typedef pair pip; typedef vectorvip; const double PI=acos(-1); const double EPS=1e-7; const int inf=1e8; const ll INF=1e16; int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; int s,t,h; vi used(30000); vvi G(30000); void f(int a){ used[a]=true; t++; rep(i,G[a].size()){ s++; int to=G[a][i]; if(used[to])continue; f(to); } } int main(){ int n; cin>>n; rep(i,n){ int a,b,c,d; cin>>a>>b>>c>>d; G[a*200+b].pb(c*200+d); G[c*200+d].pb(a*200+b); } rep(i,30000)if(G[i].size()&&!used[i]){ s=t=0; f(i); if(s/2>t)h=true; } if(!h)cout<<"YES"<