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); Map m=new HashMap(); Set s=new HashSet(); int n = in.nextInt(); String result=""; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); m.put(x,y); } if(m.size()==1) result="YES"; else { for(Map.Entry e:m.entrySet()) { s.add(e.getValue()); } if(s.size()==1) result="YES"; else result="NO"; } System.out.print(result); } }