#include #include #include using namespace std; using ll = long long; #include #include int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin>>n; atcoder::dsu uf(100*100); map,int> memo; for(int i = 0;i>a>>b>>c>>d; a--;b--;c--;d--; int ni = a * 100 + b; int nj = c * 100 + d; uf.merge(ni,nj); memo[{a,b}]++; } bool fn = false; for(auto now:uf.groups()){ int cnt = 0; for(auto e:now){ int a = e / 100; int b = e % 100; cnt += memo[{a,b}]; } int sz = now.size(); if(cnt<=sz) continue; fn = true; } if(fn) cout<<"NO\n"; else cout<<"YES\n"; }