#include #include using namespace std; string s; bool IsPalindrome(string str) { bool same = true; for (int i = 0; i < str.size(); i++) { same &= str[i] == str[str.size() - i - 1]; } return same; } void Solve() { for (int alpha = 'a'; alpha <= 'z'; alpha++) { for (int i = 0; i <= s.size(); i++) { s.insert(s.begin() + i, alpha); if (IsPalindrome(s)) { cout << s << endl; return; } s.erase(s.begin() + i); } } cout << "NA" << endl; } int main() { cin >> s; Solve(); return 0; }