#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; string S; int f(string &s){ int n = sz(s); rep(i, n / 2)if(s[i] != s[n - 1 - i])return i; return -1; } void solve(){ int N = sz(S), k = f(S); string ans, tmp1, tmp2; if(k == -1){ ans = S.substr(0, N/2) + S[N/2] + S.substr(N/2); } else{ char c1 = S[k], c2 = S[N - 1 - k]; tmp1 = S.substr(0, k) + c2 + S.substr(k); tmp2 = S.substr(0, N - k) + c1 + S.substr(N - k); if(f(tmp1) == -1)ans = tmp1; if(f(tmp2) == -1)ans = tmp2; } if(ans == "")ans = "NA"; cout << ans << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); while(cin >> S){ solve(); } }