#include <iostream>
using namespace std;
int main(){
int a;
int b;
int n;
int c;
int d;
int e;
int f;
c=0;
while(c<n){
f=0;
a=0;
b=0;
d=0;
while(d<10){
cin >>e;
if(e>a&&a>b){a=e;}
else if(e>b&&b>a){b=e;}
else if(e>a){a=e;}
else if(e>b){b=e;}
else{f=1; break;}
d=d+1;}
if(f==0){cout <<"YES"<<endl;}
if(f==1){cout <<"NO"<<endl;}
c=c+1;}