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 in = new Scanner(System.in); Set set1 = new HashSet<>(); Set set2 = new HashSet<>(); int n = in.nextInt(); for(int a0 = 0; a0 < n; a0++){ set1.add(in.nextInt()); set2.add(in.nextInt()); } System.out.println((set1.size()>1 & set2.size()>1 ) ? "NO" : "YES"); } }