#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include using namespace std; typedef long long ll; //#define int ll //#define endl "\n" typedef vector vi; typedef vector vvi; typedef pair pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i ostream & operator<<(ostream & os, vector const &); template typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple const &){} template typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple const & t){ os << (n==0?"":" ") << get(t); _ot(os, t); } template ostream & operator<<(ostream & os, tuple const & t){ _ot<0>(os, t); return os; } template ostream & operator<<(ostream & os, pair const & p){ return os << "(" << p.first << ", " << p.second << ") "; } template ostream & operator<<(ostream & os, vector const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } template inline bool chmax(T & x, T const & y){ return x inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<= r){ if(n&1) return s.substr(0,n/2) + s[n/2] + s[n/2] + s.substr(n/2+1,n/2); return s.substr(0,n/2) + 'a' + s.substr(n-n/2); } else { string left = s.substr(0,l); string right = r+1==n ? "" : s.substr(r+1); dump(left, right); int len = r-l+1; dump(len); string x = s[r] + s.substr(l,len); string y = s.substr(l,len) + s[l]; if(solve2(x)) return left + x + right; if(solve2(y)) return left + y + right; return ""; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); string n; while(cin >> n){ string ans = solve(n); if(ans.size()==0) puts("NA"); else cout << ans << endl; } }