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(); if (n < 1) return; int prevrow = in.nextInt(); int prevcol = in.nextInt(); boolean samerow = true; boolean samecol = true; for(int a0 = 0; a0 < n - 1; a0++){ int row = in.nextInt(); int col = in.nextInt(); if (row != prevrow) samerow = false; if (col != prevcol) samecol = false; } if (samerow || samecol) { System.out.println("YES"); } else { System.out.println("NO"); } } }