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 sc=new Scanner(System.in); int q=sc.nextInt(); for(int i=0;i=x||y1>=y){ if(x1>x){ x=x1; } else{ y=y1; } } else{ flag=1; break; } } if(flag==1){ System.out.println("NO"); } else{ System.out.println("YES"); } } } }