class RollingHash(): def __init__(self, s): self._mod = 2 ** 64 - 1 self._base = 4649 n = len(s) self.h = [0] * (n + 1) self.pw = [1] * (n + 5) for i in range(n): self.h[i + 1] = self.h[i] * self._base + ord(s[i]) self.h[i + 1] %= self._mod for i in range(n + 4): self.pw[i + 1] = self.pw[i] * self._base self.pw[i + 1] %= self._mod """ s[l:r]のhash値 """ def get(self, l, r): return (self.h[r] - self.h[l] * self.pw[r - l]) % self._mod S1 = list(input()) S2 = S1[::-1] R1 = RollingHash(S1) R2 = RollingHash(S2) N = len(S1) pw = R1.pw mod = R1._mod for i in range(N + 1): for s in range(26): si = s + ord("a") v1 = R1.get(0, i) * pw[N - i + 1] + R1.get(i, N) + si * pw[N - i] v2 = R2.get(0, N - i) * pw[i + 1] + R2.get(N - i, N) + si * pw[i] if (v1 - v2) % mod == 0: ans = S1[:i] + [chr(ord("a") + s)] + S1[i:] print(*ans, sep="") exit() print("NA")