S=gets.chop puts (I=(0..L=S.size/2).find{S[_1]!=S[~_1]})?[S[0,I]+S[~I]+S[I..],S[..~I]+S[I]+S[-I,L*I]].find{_1==_1.reverse}||:NA:S[0,L]+S[L]+S[L..]