#include #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) for (int i = (a) - 1; i >= 0; i--) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; typedef unsigned long long ull; const ull B = 1e8 + 7; // abcde // 12345 // edcbxa ull sh[200000], th[200000]; ull pb[200000]; string solve(string s) { string t = s; reverse(t.begin(), t.end()); int l = s.length(); pb[0] = 1; rep (i, l) { pb[i + 1] = pb[i] * B; } rep (i, l) { sh[i + 1] = sh[i] + s[i] * pb[i]; th[i + 1] = th[i] + t[i] * pb[i]; } rep (i, l + 1) { rep (j, 26) { char ch = 'a' + j; ull ssh = sh[i] + ch * pb[i] + (sh[l] - sh[i]) * B; int k = l - i; ull tth = th[k] + ch * pb[k] + (th[l] - th[k]) * B; if (ssh == tth) { s.insert(i, 1, ch); return s; } } } return "NA"; } int main() { string s; cin >> s; cout << solve(s) << endl; }