using System; using System.Collections.Generic; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; string str = Reader.ReadLine(); string ans = this.GetKaibun(str, true); if(ans.Length == 0) { ans = "NA"; } Console.WriteLine(ans); } private string GetKaibun(string target, bool canIns) { int topIdx = 0; int bottomIdx = target.Length - 1; while (target[topIdx] == target[bottomIdx] && topIdx < bottomIdx) { topIdx++; bottomIdx--; } if(target.Length == 1) { if(canIns) { return target + target; } else { return target; } } if(topIdx >= bottomIdx) { return target.Substring(0, topIdx) + target[topIdx] + target.Substring(topIdx); } else if(!canIns) { return string.Empty; } else { string mid = target.Substring(topIdx, bottomIdx + 1 - topIdx); string tmp1 = this.GetKaibun(mid.Substring(1), false); if(tmp1.Length == 0) { tmp1 = this.GetKaibun(mid.Substring(0, mid.Length - 1), false); if(tmp1.Length > 0) { mid = mid[mid.Length - 1] + mid; } } else { mid = mid + mid[0]; } if(tmp1.Length > 0) { if(topIdx == 0) { return mid; } else { return target.Substring(0,topIdx) + mid + target.Substring(bottomIdx + 1); } } else { return string.Empty; } } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" dedc "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }