import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; void main() { auto s = readln.chomp; writeln(calc(s)); } string calc(string s) { foreach (i; 0..s.length/2) { if (s[i] != s[$-i-1]) { auto s2 = s[$-i-1] ~ s[i..$-i]; if (isKaibun(s2)) return s[0..i] ~ s2 ~ s[$-i..$]; auto s3 = s[i..$-i] ~ s[i]; if (isKaibun(s3)) return s[0..i] ~ s3 ~ s[$-i..$]; return "NA"; } } if (s.length % 2 == 0) return s[0..s.length/2] ~ "a" ~ s[s.length/2..$]; else return s[0..s.length/2] ~ s[s.length/2] ~ s[s.length/2] ~ s[s.length/2+1..$]; } bool isKaibun(string s) { foreach (i; 0..s.length/2) if (s[i] != s[$-i-1]) return false; return true; }