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(); HashMap hm=new HashMap(); HashMap hm2=new HashMap(); for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); if(hm.containsKey(x)) { int cc=hm.get(x); hm.put(x,cc+1); } else { hm.put(x,1); } if(hm2.containsKey(y)) { int cc=hm2.get(y); hm2.put(y,cc+1); } else { hm2.put(y,1); } } boolean ans=false; for(int m:hm.keySet()) { int cc=hm.get(m); if(cc==n) { ans=true; } } for(int m:hm2.keySet()) { int cc=hm2.get(m); if(cc==n) { ans=true; } } if(ans) { System.out.println("YES"); } else { System.out.println("NO"); } } }