//https://ncode.syosetu.com/n4830bu/238/ #include using namespace std; int main() { string s; cin >> s; int l = 0, r = s.size() - 1; while (true) { if (s[l] != s[r]) break; if (r - l <= 2) { if (s.size() % 2 == 0) cout << s.substr(0, l + 1) + "a" + s.substr(r, l + 1) << endl; else cout << s.substr(0, l + 1) + s[(l + 1)] + s[(l + 1)] + s.substr(r, l + 1) << endl; return 0; } l++; r--; } string t = s; t.insert(l, s.substr(r, 1)); if (equal(t.begin(), t.end(), t.rbegin())) { cout << t << endl; return 0; } t = s; t.insert(r + 1, s.substr(l, 1)); if (equal(t.begin(), t.end(), t.rbegin())) { cout << t << endl; return 0; } cout << "NA" << endl; }