#include #include #include #include #include #define N 200005 #define INF 0x4fffffff #define PI 3.14159265358979323846 #define MM 1000000007 #define rep(i,j,k) for(i=j;i<=k;i++) #define rrep(i,j,k) for(i=j;i>=k;i--) using namespace std; string str,s; int i,j,k,l,T,flag; int work(int l, int r, int p){ int ff=1; while((l<=r)&&(str[l]==s[p])){ p++; l++; } if (l==r+1) return 1; else return 0; } int main(){ scanf("%d",&T); str="anniversary"; getline(cin,s); while(T--){ getline(cin,s); l=s.length(); flag=0; rep(i,0,8) if (!flag) rep(j,i+1,9){ k=0; while((k=l) continue; k+=i+1; while((k=l) continue; k+=(j-i); while((k=l) continue; flag=1; break; } if (flag) cout<<"YES"<