import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } const int[] dy = [-1, 0, 1, 0]; const int[] dx = [0, 1, 0, -1]; struct Point { int y, x; } const Z = 120; void main() { int N; readf("%d\n", &N); Point[][Point] G; foreach (i; 0 .. N) { int sy, sx, gy, gx; readf("%d %d %d %d\n", &sy, &sx, &gy, &gx); G[Point(sy, sx)] ~= Point(gy, gx); G[Point(gy, gx)] ~= Point(sy, sx); } bool[Point] used; bool dfs(in Point p, in Point prev) { if (p in used) { // 繧ゅ←縺」縺ヲ譚・縺溘i縲∵悴菴ソ逕ィ縺ョ霎コ縺梧ョ九▲縺ヲ縺・l縺ー繧「繧ヲ繝医€∵ョ九▲縺ヲ縺・↑縺代l縺ー繧サ繝シ繝・//// foreach (next; G[p]) { if (next == prev) continue; if (next !in used) return false; } return true; } used[p] = true; foreach (next; G[p]) { if (next == prev) continue; if (! dfs(next, p)) return false; } return true; } foreach (int y; 0 .. Z) { foreach (int x; 0 .. Z) { if (Point(y, x) !in G) continue; used.clear(); if (! dfs(Point(y, x), Point(-1, -1))) { writeln("NO"); return; } } } writeln("YES"); }