#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define fst first #define snd second using ll=long long; using pii=pair;using pll=pair;using pil=pair;using pli=pair; using vs=vector;using vvs=vector;using vvvs=vector; using vb=vector;using vvb=vector;using vvvb=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templateistream&operator>>(istream&is,pair&P){is>>P.fst;is>>P.snd;return is;} templateT read(){T t;cin>>t;return t;} templateostream&operator<<(ostream&o,const pair&p){return o<<'('<ostream&operator<<(ostream&o,const vector&t){o<<"{";rep(i,sz(t))o<void e_r_r(vs::iterator it,T a,Args... args){cerr<substr((*it)[0]==' ',it->length())<<" = "<> G; vector match; vector used; BipartiteMatching(int V) : V(V), G(V), match(V, -1), used(V) {} void add_edge(int u, int v) { G[u].push_back(v); G[v].push_back(u); } int matching() { int res = 0; for (int v = 0; v < V; v++) { if (match[v] < 0) { fill(used.begin(), used.end(), 0); if (dfs(v)) { res++; } } } return res; } private: bool dfs(int v) { used[v] = true; for (int i = 0; i < (int) G[v].size(); i++) { int u = G[v][i], w = match[u]; if (w < 0 || (!used[w] && dfs(w))) { match[v] = u; match[u] = v; return true; } } return false; } }; bool solve() { int n = read(); vi U(n), V(n); int P[112][112]; memset(P, 0xff, sizeof(P)); int m = 0; rep(i, n) { int a = read(); int b = read(); int c = read(); int d = read(); if (P[a][b] != -1) { U[i] = P[a][b]; } else { P[a][b] = U[i] = m++; } if (P[c][d] != -1) { V[i] = P[c][d]; } else { P[c][d] = V[i] = m++; } } BipartiteMatching bm(n+m); rep(i, n) { bm.add_edge(i, n+U[i]); bm.add_edge(i, n+V[i]); } int match = bm.matching(); return match == n; } void Main() { cout << (solve() ? "YES" : "NO") << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }