#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); #define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);} #define rep(v,e) for(long v=0;v=1<<10){ M e=m_zero(); e.v[0][1][0][0]=1; M m=e; for(--l;l;l>>=1){ if(l&1){ m=m_mul(m,e); } e=m_mul(e,e); } rep(i,26){ rep(j,26){ if(i!=j){ rep(a,26){ rep(b,26){ d2[i][j]+=m.v[i==a][i==b][j==a][j==b]*d1[a][b]%MD; } } } } } nextd(); }else{ for(;--l>=0;){ rep(i,26){ long s=0; rep(j,26){ s+=d1[j][i]; } rep(j,26){ d2[i][j]=i==j?0:s-d1[j][i]; } } nextd(); } } long c=*rp++-'a'; if(c<0){ break; } rep(i,26){ if(i!=c){ rep(j,26){ if(j!=c){ d2[i][c]+=d1[j][i]; } } } } nextd(); } long z=0; rep(i,26){ rep(j,26){ z+=d1[i][j]; } } z%=MD; char wbuf[64],*wp=wbuf+sizeof wbuf; wt(z); write(1,wp,wbuf+sizeof wbuf-wp); _exit(0); }