#include #include #include #include #include #include using namespace std; int main() { int n; string s; cin >> s; int idx_f = 0; int idx_b = s.size() - 1; bool inserted = false; while(idx_f <= idx_b) { if (s[idx_f] != s[idx_b] || abs(idx_b - idx_f) <= 1) { s.insert(idx_b + 1, 1, s[idx_f]); inserted = true; break; } idx_f++; idx_b--; } if (!inserted) { cout << "NA" << endl; return 0; } idx_f = 0; idx_b = s.size() - 1; while(idx_f <= idx_b) { if (s[idx_f] != s[idx_b]) { cout << "NA" << endl; return 0; } idx_f++; idx_b--; } cout << s << endl; return 0; }