#include <fstream> #include <string.h> using namespace std; int main() { ifstream f("times.in"); ofstream g("times.out"); char s[5] ; int n , i , a , b , c , d ; f>>n ; for ( i=0 ; i<n ; i++ ) { f>>s; strcpy(s+2 , s+3 ) ; a=s[0]; b=s[1]; c=s[2]; d=s[3] ; if ( a==b-1 && b==c-1 && c==d-1 ) { g<<"YES"<<endl; }else if ( a==b && b==c && c==d ) { g<<"YES"<<endl; }else if ( a==c && b==d ) { g<<"YES"<<endl; }else if ( c==0 && d==1 ) { g<<"YES"<<endl; }else g<<"NO"<<endl ; s[0]=NULL; } }