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) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); Set x = new HashSet<>(); Set y = new HashSet<>(); for (int i = 0; i < num; i++) { x.add(sc.nextInt()); y.add(sc.nextInt()); } sc.close(); if (x.size() == 1 || y.size() == 1) { System.out.println("YES"); } else { System.out.println("NO"); } } }