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(); LinkedHashSet xList=new LinkedHashSet(); LinkedHashSet yList=new LinkedHashSet(); boolean xVal=false; boolean yVal=false; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); xList.add(x); yList.add(y); } if(xList.size()>1 && yList.size()==1){ System.out.print("YES"); } else if(yList.size()>1 && xList.size()==1){ System.out.print("YES"); } else System.out.print("NO"); } }