import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.Map.Entry; public class _483 { public static void main(String[] args) throws IOException { new _483().solve(); } void solve() throws IOException { try (final Scanner in = new Scanner(System.in)) { int n = in.nextInt(); TreeMap> g = new TreeMap<>(); for (int i = 0; i < n; i++) { int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); int k1 = x1 * 200 + y1; int k2 = x2 * 200 + y2; TreeSet es1 = g.getOrDefault(k1, new TreeSet<>()); TreeSet es2 = g.getOrDefault(k2, new TreeSet<>()); es1.add(k2); es2.add(k1); g.put(k1, es1); g.put(k2, es2); } TreeMap deg = new TreeMap<>(); for (Entry> e : g.entrySet()) { deg.put(e.getKey(), e.getValue().size()); } while (true) { TreeSet ks = new TreeSet<>(g.keySet()); boolean updated = false; boolean all2 = true; for (int k : ks) { all2 &= g.get(k).size() == 2 || g.get(k).size() == 0; if (g.get(k).size() == 1) { g.get(g.get(k).first()).remove(k); g.remove(k); updated = true; } } // dump(all2, updated); if (!updated) { System.out.println(all2 ? "YES" : "NO"); break; } } } } // for debug static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } }