#include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) typedef long long ll; int N; string s; string ans; void dfs(int a, int b, bool used, string const& str) { if( (N+used) % 2 == 0 && a - 1 == b ) { string t = str; reverse(t.begin(), t.end()); string u = !used ? "x" : ""; ans = str + u + t; return; } if( (N+used) % 2 == 1 && a - 2 == b ) { string t = str; reverse(t.begin(), t.end()); string u = !used ? "x" : ""; ans = str + u + t.substr(1); return; } if(s[a] == s[b]) { dfs(a+1, b-1, used, str + s[a]); } else if(!used) { dfs(a+1, b, true, str + s[a]); dfs(a, b-1, true, str + s[b]); } } int main() { cin >> s; N = s.size(); dfs(0, N-1, false, ""); if(ans.empty()) { cout << "NA\n"; } else { cout << ans << endl; } return 0; }