#include #include #include // *********************** // for debug #define DEBUG2 #define NOP do{}while(0) #ifdef DEBUG #define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0) #define TRACECR do{printf("\n");fflush(stdout);}while(0) #else #define TRACE(...) NOP #define TRACECR NOP #endif #define PRINCR printf("\n") #define NOCR(strig) do{char *p;p=strchr(strig,'\n');if(p)*p='\0';}while(0) // for stdio #define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0) static char *getinput( char* str ); // for readaility typedef long long lolong; const int INF = 1e9; const int MOD = 1e9+7; const lolong LINF = 1e18; #define YES(a) printf("%s",((a)?("YES":"NO"))) #define Yes(a) printf("%s",((a)?("Yes":"No"))) #define POSSIBLE(a) printf("%s",((a)?("POSSIBLE":"IMPOSSIBLE"))) #define Possible(a) printf("%s",((a)?("Possible":"Impossible"))) #define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0) #define REP(a,b) for(int a=0;a<(b);++a) #define REP1(a,b) for(int a=1;a<=(b);++a) #define FLOOP(a,b) for(a=0;a<(b);++a) #define FLOOP1(a,b) for(a=1;a<=(b);++a) // *********************** // stdioから空白区切りの単語を1つだけ読み取ってくる(可変長入力の場合) static char *getinput( char* str ) { char c; char *cp; cp = &str[0]; c = fgetc(stdin); while( c != EOF ) { if( ( c == ' ')||( c == '\n') ) break; *cp++ = c; c = fgetc(stdin); } *cp = '\0'; return &str[0]; } // *********************** // 個別リテラル #define INPBUF (8*128+2) // *********************** // 外部変数 // *********************** // *********************** int cnt1 = 12; int cnt2 = 12; void strchange( char str[] ) { int i; int k; do { cnt1++; if( cnt1 > 121 ) { cnt1 = 0; cnt2--; } i = cnt1 % 11; k = (cnt1 / 11) % 11; if( (i & 1 )!= (k & 1) ) continue; if( i == k ) continue; TRACE("change %d,%d [%s]",i,k,str); SWAP( char , str[i] , str[k] ); TRACE("[%s]\n",str); break; } while(1); } // *********************** // *********************** int onaji( char str[] , void *mp , int limit ) { unsigned char *cp; cp = (char *)mp; REP(i,limit) { int onaflg = 1; REP(k,13) if( *(cp+ k) != str[k] ) { onaflg = 0; break; } if( onaflg ) { TRACE("%s == %s\n",cp , str); return 1; // 同じものがある } cp += 13; } return 0; // 同じものがない } // *********************** int main(void) { char name[16]; char *mem; char *mp; int query; strcpy( name , "inabameguru"); scanf("%d", &query); if( query ) { if(( mem = malloc( 13 * query ) ) == NULL ) return 13; mp = mem; REP(i,query) { scanf("%s", mp ); //TRACE("get[%s]\n", mp); mp += 13; } /* REP(i,400) { strchange( name ); printf("%s\n",name); } */ do { TRACE("t:%s\n",name); strchange( name ); if( cnt2 < 0 ) { printf("NO\n"); return 0; } } while( onaji( name, mem , query) ); } printf("%s\n", name ); free( mem ); return 0; }