#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define rep(v,e) for(typeof(e) v=0;v='a';){ s[j++]=c; v+=ch[c-'a']; } rep(c,26){ int h=hash_add(v+ch[c]); hn[h]=hn[h]?-1:i+1; } } } void f2(){ rep(h,1<0){ char*s=ss[hn[h]-1]; unsigned v=hash[h]; int j=0; for(int c;c=s[j++],c>='a';){ v-=ch[c-'a']; } rep(c,26){ if(ch[c]==v){ s[j-1]=c+'a'; write(1,s,j); _exit(0); } } _exit(1); } } write(1,"-1",2); _exit(0); } int main(){ f0(); f1(); f2(); }