#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, t, u; string ans; bool dfs(int a, int b, bool used) { if( (N+used) % 2 == 0 && a - 1 == b ) { t = ans; reverse(t.begin(), t.end()); u = !used ? "x" : ""; cout << ans << u << t << endl; return true; } if( N % 2 == 1 && !used && a - 2 == b) { t = ans; reverse(t.begin(), t.end()); u = ans[b+1]; cout << ans << u; cout << t.substr(1) << endl; return true; } if( (N+used) % 2 == 1 && a - 2 == b ) { t = ans; reverse(t.begin(), t.end()); if(!used) u = ans[a+1]; cout << ans << u; cout << t.substr(1) << endl; return true; } if(s[a] == s[b]) { ans += s[a]; if(dfs(a+1, b-1, used)) { return true; } ans.pop_back(); } else if(!used) { ans += s[a]; if(dfs(a+1, b, true)) { return true; } ans.back() = s[b]; if(dfs(a, b-1, true)) { return true; } ans.pop_back(); } return false; } int main() { cin >> s; N = s.size(); if(N == 1) { cout << s << s << endl; } else { if(!dfs(0, N-1, false)) { cout << "NA\n"; } } return 0; }