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[][] ar = new int[n][2]; HashSet hs = new HashSet(); HashSet hs1 = new HashSet(); for(int a0 = 0; a0 < n; a0++){ hs.add(in.nextInt()); hs1.add(in.nextInt()); } if(hs.size() == 1){ System.out.println("YES"); } else if(hs1.size() == 1){ System.out.println("YES"); } else{ System.out.println("NO"); } } }