#include <iostream> #include <algorithm> #include <cstdio> #include <queue> #include <vector> using namespace std; bool isPalin(string s){ for(int ctr1=0;ctr1<(s.length()+1)/2;ctr1++){ if(s[ctr1]!=s[s.length()-1-ctr1]) return false; } return true; } typedef long long ll; int main() { string s; cin>>s; for(int ctr1=0;ctr1<(s.length()+1)/2;ctr1++){ if(s[ctr1]!=s[s.length()-1-ctr1]){ string t=s; string ap; ap+=s[s.length()-1-ctr1]; t.insert(ctr1,ap); if(isPalin(t)){ cout<<t; return 0; } t=s; ap=s[ctr1]; t.insert(s.length()-ctr1,ap); if(isPalin(t)){ cout<<t; return 0; } cout<<"NA"; return 0; } } string t; t+=s[(s.length())/2]; s.insert(s.length()/2,t); cout<<s; return 0; }