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 tmp1 = this.GetKaibun(target.Substring(1), false); if(tmp1.Length == 0) { tmp1 = this.GetKaibun(target.Substring(0, target.Length - 1), false); if(tmp1.Length == 0) { return string.Empty; } else { return target[target.Length - 1] + target; } } else { return target + target[0]; } } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" kitayuta "; 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(); } }