#include #include #include using namespace std; int par[202020]; int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } bool unite(int x, int y) { x = find(x); y = find(y); if (x == y) return false; par[x] = y; return true; } int main() { iota(par, par + 202020, 0); int n; cin >> n; vector cycle(202020); for (int i = 0; i < n; i++) { int y1, x1, y2, x2; cin >> y1 >> x1 >> y2 >> x2; int u = y1 * 200 + x1; int v = y2 * 200 + x2; if (!unite(u, v)) { cycle[u]++; } } for (int i = 0; i < 202020; i++) { if (find(i) != i) { cycle[find(i)] += cycle[i]; } } for (int i = 0; i < 202020; i++) { if (cycle[i] >= 2) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }