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(); int row=-1; int col=-1; int flag=-1; for(int a0 = 0; a0 < n; a0++){ int flagTemp=-1; int rowTemp = in.nextInt(); int colTemp = in.nextInt(); if(a0==0){ row=rowTemp; col=colTemp; } else{ if(rowTemp!=row & colTemp!=col){ System.out.println("NO"); return; } if(a0==1){ if(rowTemp==row & colTemp!=col){ flag=0; } if(colTemp==col & rowTemp!=row){ flag=1; } } if((rowTemp==row & colTemp!=col & flag==0 )|(colTemp==col & rowTemp!=row & flag==1)){ continue; } else{ System.out.println("NO"); return; } } } System.out.println("YES"); } }