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 prevx = 0, prevy = 0; for(int a0 = 0; a0 < n; a0++){ int curx = in.nextInt(); int cury = in.nextInt(); if(a0 != 0){ if(curx == prevx || cury == prevy) { } else{ System.out.println("NO"); return; } } prevx = curx; prevy = cury; } System.out.println("YES"); } }