#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { string s; cin >> s; int n = s.size(); bool ok = true; for (int i = 1, j = n-1; i < j; i++, j--) { if (s[i] != s[j]) { ok = false; break; } } if (ok) { std::cout << s+s[0] << std::endl; return 0; } ok = true; for (int i = 0, j = n-2; i < j; i++, j--) { if (s[i] != s[j]) { ok = false; break; } } if (ok) { std::cout << s[n-1]+s << std::endl; return 0; } for (int i = 0, j = n-1; i < j; i++, j--) { if (s[i] != s[j]) { ok = true; for (int k = i+1, l = j; k < l; k++, l--) { if (s[k] != s[l]) { ok = false; } } if (ok) { std::cout << s.substr(0, j+1)+s[i]+s.substr(j) << std::endl; return 0; } ok = true; for (int k = i, l = j-1; k < l; k++, l--) { if (s[k] != s[l]) { ok = false; } } if (ok) { std::cout << s.substr(0, i)+s[j]+s.substr(i-1) << std::endl; return 0; } std::cout << "NA" << std::endl; return 0; } } std::cout << s.substr(0, n/2)+s[n/2]+s.substr(n/2) << std::endl; }