#include using namespace std; int A[101]; int B[10001]; vector adj[101]; bool visited[101]; bool dfs(int a) { visited[a] = true; for (auto b : adj[a]) { if (B[b] == -1 || !visited[B[b]] && dfs(B[b])) { A[a] = b; B[b] = a; return true; } } return false; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n; int r0, c0, r1, c1; cin >> n; for (int i = 0; i < n; i++) { cin >> r0 >> c0 >> r1 >> c1; int u = r0 * 100 + c0; int v = r1 * 100 + c1; adj[i].push_back(u); adj[i].push_back(v); } int res = 0; memset(A, -1, sizeof(A)); memset(B, -1, sizeof(B)); for (int i = 0; i < n; i++) { if (A[i] == -1) { memset(visited, false, sizeof(visited)); if (dfs(i)) { res++; } } } if (res == n) { cout << "YES" << '\n'; } else { cout << "NO" << '\n'; } return 0; }