#include using namespace std; using i64 = int64_t; using vi = vector; using vvi = vector; int main() { string s; cin >> s; if (s.size() == 1) { cout << s.front() << s.front() << endl; return 0; } deque hoge; for (char c: s) { hoge.push_back(c); } string pref; while (hoge.size() > 1 && hoge.front() == hoge.back()) { pref.push_back(hoge.front()); hoge.pop_front(); hoge.pop_back(); } string suf(pref); reverse(suf.begin(), suf.end()); if (hoge.size() == 1) { cout << pref << hoge.front() << hoge.front() << suf << endl; return 0; } else if (hoge.empty()) { cout << pref << "a" << suf << endl; return 0; } deque fuga(hoge), piyo(hoge); fuga.push_back(hoge.front()); piyo.push_front(hoge.back()); auto tostr = [](deque d) { string ret = ""; for (char c: d) { ret += c; } return ret; }; string sf = tostr(fuga), sp = tostr(piyo); auto ok = [](string t) { string u(t); reverse(u.begin(), u.end()); return t == u; }; if (ok(sf)) { cout << pref << sf << suf << endl; return 0; } else if (ok(sp)) { cout << pref << sp << suf << endl; return 0; } cout << "NA" << endl; }