

class Integer
    def to_express
        suffix = ["", :Man, :Oku, :Cho, :Kei, :Gai, :Jo, :Jou, :Ko, :Kan, :Sei, :Sai, :Gok, :Ggs, :Asg, :Nyt, :Fks, :Mts]
        res = []
        for i in 0 .. 17
            value = (0 ... 4).flat_map{|j| self.to_s[i * -4 - 4 + j]}.drop_while{|s| s == "0"}.join
            res << ((value == "") ? value : (value + suffix[i].to_s))
        end
        res.reverse.join
    end 
end
while(true)
    m, n = gets.split(' ').map(&:to_i)
    break if m == 0
    target = m ** n
    puts target.to_express
end
