#include #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; bool pal(string s) { rep (i, s.length()) { if (s[i] != s[s.length() - i - 1]) { return false; } } return true; } int main() { string s; cin >> s; string t = s; reverse(t.begin(), t.end()); int pos = s.length() / 2; rep (i, s.length()) { if (s[i] != t[i]) { pos = i; break; } } string ansA = t; string ansB = t; ansA.insert(pos, string(1, ansA[ansA.length() - pos - 1])); ansB.insert(ansB.length() - pos, string(1, ansB[pos])); if (pal(ansA)) { cout << ansA << endl; } else if (pal(ansB)) { cout << ansB << endl; } else { cout << "NA" << endl; } }