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 xo=0,yo=0; int x1=0,y1=0; int co=1; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); int y = in.nextInt(); if(co==1) { x1=x; y1=y; co=2; } if(x==x1) xo++; if(y==y1) yo++; } if(xo==n||yo==n) System.out.println("YES"); else System.out.println("NO"); } }