#include using namespace std; bool isKaibun(string s) { int n = s.length(); for (int i = 0; i < n / 2; i++) { if (s[i] != s[n - 1 - i]) return false; } return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.length(); string c; if (isKaibun(s)) { c = s[n / 2]; s.insert(n / 2, c); cout << s << endl; return 0; } int cnt = 0, idx = -1; for (int i = 0; i < (n - 1) / 2; i++) { cnt += (s[i] != s[n - 1 - i - cnt]); if (cnt > 1) break; if (cnt == 1 && idx == -1) { idx = i; c = s[n - 1 - i]; i--; } } if (cnt == 0) { idx = (n - 1) / 2; c = s[n / 2]; } if (cnt <= 1) { s.insert(idx, c); cout << s << endl; return 0; } cnt = 0; idx = -1; reverse(s.begin(), s.end()); for (int i = 0; i < (n - 1) / 2; i++) { cnt += (s[i] != s[n - 1 - i - cnt]); if (cnt > 1) break; if (cnt == 1 && idx == -1) { idx = i; c = s[n - 1 - i]; i--; } } if (cnt == 0) { idx = (n - 1) / 2; c = s[n / 2]; } if (cnt <= 1) { s.insert(idx, c); cout << s << endl; return 0; } cout << "NA" << endl; return 0; }