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