S = gets.chomp RS = S.reverse N = S.size if S == RS l = N / 2 S.insert(l, S[l]) puts S else idx = (0...N).find { |i| S[i] != RS[i] } r_idx = N - idx - 1 S.insert(r_idx + 1, S[idx]) if S == S.reverse puts S else puts 'NA' end end