main :: IO ()
main = do
  ls <- getContents
  let ls' = map split2 . lines $ ls
  mapM_ putStrLn $ solve ls'

split2 :: String -> [String]
split2 [] = []
split2 (x:y:r) = [x,y]:(split2 r)
split2 [x] = [[x]]
table = zip ["11","12","13","14","15",
             "21","22","23","24","25",
             "31","32","33","34","35",
             "41","42","43","44","45",
             "51","52","53","54","55",
             "61","62","63","64","65"]
        (['a'..'z'] ++ ".?! ")

solve :: [[String]] -> [String]
solve xs = map change xs
  where
    change :: [String] -> String
    change xs
      | all (isInTable table) xs = change' xs
      | otherwise = "NA"
      where
        isInTable :: [(String,Char)] -> String -> Bool
        isInTable [] xs = False
        isInTable ((a,b):r) xs
          | xs == a = True
          | otherwise = isInTable r xs
        change' :: [String] -> String
        change' [] = []
        change' (x:xs) = (toC x table):(change xs)
          where
            toC :: String -> [(String,Char)] -> Char
            toC x ((a,b):r)
              | x == a = b
              | otherwise = toC x r