#include int main() { std::string str; std::string str2; int p; char c; std::cin >> str; str2 = str; std::reverse(str2.begin(), str2.end()); int n = str.size(); for(int i = 0; i < str.size(); ++i) { if( str[i] != str2[i] ) { p = i; break; } } if( p > str.size()/2 ) { if( str.size() % 2 == 0 ) { std::stringstream ss; for(int i = 0; i < n/2; ++i) { ss << str[i]; } ss << 'a'; for(int i = n/2; i < n; ++i) { ss << str[i]; } str = ss.str(); str2 = str; std::reverse(str2.begin(), str2.end()); if( str == str2 ) { std::cout << str << std::endl; } else { std::cout << "NA" << std::endl; } return 0; } else { std::cout << "NA" << std::endl; return 0; } } if( p != 0 ) { c = str[str.size()-p-1]; } else { p = n; c = str[0]; } std::stringstream ss; for(int i = 0; i < p; ++i) { ss << str[i]; } ss << c; for(int i = p; i < n; ++i) { ss << str[i]; } str = ss.str(); str2 = str; std::reverse(str2.begin(), str2.end()); if( str == str2 ) { std::cout << str << std::endl; } else { std::cout << "NA" << std::endl; } return 0; }