main :: IO ()
main = do
  mn <- getLine
  if mn == "0 0"
    then return ()
    else do
      let [m,n] = map read . words $ mn
          taniL = ["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"]
      putStrLn $ solve (m `pow` n) taniL
      main
pow :: Integer -> Integer -> Integer
pow m n = pow' m n 1
  where
    pow' :: Integer -> Integer -> Integer -> Integer
    pow' m 0 a = a
    pow' m n a = pow' m (n-1) (a*m)
solve :: Integer -> [String] -> String
solve 0 _ = ""
solve x (y:ys) = (solve (x `div` 10000) ys) ++ if (x `mod` 10000 == 0) then "" else ((show (x `mod` 10000)) ++ y)