#include using namespace std; struct Bipartite_Matching { vector< vector< int > > graph; vector< int > match; vector< bool > used; Bipartite_Matching(int n) { graph.resize(n); } void add_edge(int u, int v) { graph[u].push_back(v); graph[v].push_back(u); } bool dfs(int v) { used[v] = true; for(int i = 0; i < graph[v].size(); i++) { int u = graph[v][i], w = match[u]; if(w == -1 || (!used[w] && dfs(w))) { match[v] = u; match[u] = v; return (true); } } return (false); } int bipartite_matching() { int ret = 0; match.assign(graph.size(), -1); for(int i = 0; i < graph.size(); i++) { if(graph[i].empty()) continue; if(match[i] == -1) { used.assign(graph.size(), false); ret += dfs(i); } } return (ret); } }; int main() { int N, R[100]; cin >> N; Bipartite_Matching match(1145141); for(int i = 0; i < N; i++) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; match.add_edge(i, x1 * 100 + y1 * 10000); match.add_edge(i, x2 * 100 + y2 * 10000); } if(match.bipartite_matching() == N) { cout << "YES" << endl; } else { cout << "NO" << endl; } }