#define PROB Training #include #include #define f(x,y,z) for(int x = (y),__ = (z);x < __;++x) #define g(x,y,z) for(int x = (y),__ = (z);x <= __;++x) #define gd(x,y,z) for(int x = (y),__ = (z);x >= __;--x) #define CLR(X) memset(X,0,sizeof(X)) #define SET(ARR,X) memset(ARR,X,sizeof(ARR)) #define R(X,Y) f(X,0,Y) #define G(x,y) g(X,0,Y) #define MAXN 1024 #ifdef WIN32 #define LLD "%I64d" #define LLU "%I64u" #else #define LLD "%lld" #define LLU "%llu" #endif typedef long long LL; typedef long double real; char str[MAXN]; char b[MAXN],q[MAXN],t[MAXN]; char anni[] = "anniversary"; int ans,T,sz; bool flag; char nul[] = ""; char *a,*s,*d; int main(){ scanf("%d",&T); while (T--){ scanf("%s",str);sz = strlen(anni);flag = 1; f(i,1,sz){f(j,i + 1,sz){ // strcpy(b,nul);strcpy(q,nul);strcpy(t,nul); f(k,0,i)b[k] = anni[k];b[i] = '\0'; f(k,i,j)q[k - i] = anni[k];q[j - i] = '\0'; f(k,j,sz)t[k - j] = anni[k];t[sz - j] = '\0'; // puts(strstr(str,b) + strlen(b)); // if (strstr(str,b) + strlen(b) < strstr(str,q))puts("str"); a = strstr(str,b); if (a != NULL){ s = strstr(a + strlen(b),q); if (s != NULL){ d = strstr(s + strlen(q),t); if (d != NULL){ puts("YES"); flag = 0; break; } } } // printf("%s %s %s\n",b,q,t); }if (!flag)break; } if (flag)puts("NO"); } return 0; } /* 1 annivddfdersewwefary 2 annivddfdersewwefary nniversarya */