#include using namespace std; typedef long long ll; struct BipartiteMatching { int V; vector > G; vector match; vector used; BipartiteMatching(int v) { V = v; G = vector >(v, vector(v)); match = vector(v); used = vector(v); } void add_edge(int v, int u) { G[v][u] = G[u][v] = true; } bool dfs(int v) { used[v] = true; for(int i = 0; i < V; i++) { if(!G[v][i]) continue; int u = i, w = match[u]; if(w < 0 || (!used[w] && dfs(w))) { match[v] = u; match[u] = v; return true; } } return false; } int calc() { int res = 0; fill(match.begin(), match.end(), -1); for(int v = 0; v < V; v++) { if(match[v] < 0) { fill(used.begin(), used.end(), false); if(dfs(v)) { res++; } } } return res; } }; typedef pair P; int x[100][4]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; map m; for(int i = 0; i < N; i++) { for(int j = 0; j < 4; j++) { cin >> x[i][j]; } m[{x[i][0], x[i][1]}] = 0; m[{x[i][2], x[i][3]}] = 0; } int cnt = 0; for(auto v : m) { m[v.first] = cnt++; } BipartiteMatching bp(N + m.size()); for(int i = 0; i < N; i++) { bp.add_edge(i, N + m[{x[i][0], x[i][1]}]); bp.add_edge(i, N + m[{x[i][2], x[i][3]}]); } if(bp.calc() == N) { cout << "YES" << endl; } else { cout << "NO" << endl; } }