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