using System; using System.Collections.Generic; using System.Linq; namespace YukiCoderNo238 { class Program { static void Main() { string input = LIB.IO.R(); char[] inputarray = input.ToCharArray(); int count = inputarray.Count(); bool flag = false; bool ba = false; int mem = 0; char c = ' '; for (int i = 0, j = count - 1; i < count / 2 + count % 2; i++, j--) { if (inputarray[i] != inputarray[j]) { if (flag == true) { flag = false; ba = true; for (int k = 0, l = count - 1; k < count / 2; k++, l--) { if (inputarray[k] != inputarray[l]) { if (flag == true) { LIB.IO.W("NA"); LIB.IO.WFLUSH(); return; } else { flag = true; mem = k; c = inputarray[l]; k--; } } } } else { flag = true; mem = j; c = inputarray[i]; j++; } } } if (flag == true) { if (ba == false) { LIB.IO.W(new string(inputarray, 0, mem + 1), false); LIB.IO.W(c, false); if (mem < count - 1) { LIB.IO.W(new string(inputarray, mem + 1, count - mem - 1), false); } LIB.IO.W(""); } else { LIB.IO.W(new string(inputarray, 0, mem), false); LIB.IO.W(c, false); if (mem < count - 1) { LIB.IO.W(new string(inputarray, mem, count - mem), false); } LIB.IO.W(""); } } else { if ((count % 2) == 0) { LIB.IO.W(new string(inputarray, 0, count / 2), false); LIB.IO.W('a', false); LIB.IO.W(new string(inputarray, count / 2, count / 2), false); LIB.IO.W(""); } else { if (count == 1) { LIB.IO.W(inputarray[0], false); LIB.IO.W(inputarray[0], false); } else { LIB.IO.W(new string(inputarray, 0, count / 2), false); LIB.IO.W(inputarray[count / 2], false); LIB.IO.W(new string(inputarray, count / 2 , count / 2 + 1), false); } LIB.IO.W(""); } } LIB.IO.WFLUSH(); } } } namespace LIB { public class IO { private const int WMAX = 1000; private static string WSTRING = ""; public static T R() { return (T)(Convert.ChangeType(R(), typeof(T))); } public static T[] R(char splitter = ' ') { return R().Split(splitter).Select(v => UTILITY.PARSE(v)).ToArray(); } public static T[] R(int length) { T[] ret = new T[length]; for (int i = 0; i < length; i++) { ret[i] = R(); } return ret; } public static T[][] R(int length, char splitter = ' ') { T[][] ret = new T[length][]; for (int i = 0; i < length; i++) { ret[i] = R(splitter); } return ret; } private static string R() { return Console.ReadLine(); } public static void W(object value, bool addLineFeed = true) { WSTRING += UTILITY.PARSE(value); if (addLineFeed == true) { WSTRING += "\n"; } if (WSTRING.Count() >= WMAX) { WFLUSH(); } } public static void WFLUSH() { Console.Write(WSTRING); WSTRING = ""; } } public class UTILITY { public static T PARSE(object value) { return (T)(Convert.ChangeType(value, typeof(T))); } } }