import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { try (final Scanner in = new Scanner(System.in)) { final Set xs = new HashSet<>(), ys = new HashSet<>(); final int n = in.nextInt(); for (int i = 0; i < n; i++) { xs.add(in.nextInt()); ys.add(in.nextInt()); } System.out.println(((xs.size() == 1) || (ys.size() == 1)) ? "YES" : "NO"); } } }