k = %[Man Oku Cho Kei Gai Jo Jou Ko Kan Sei Sai Gok Ggs Asg Nyt Fks Mts].split.to_a
while gets
  m, n = $_.split.map(&:to_i)
  break if m == 0 && n == 0
  v = m ** n
  a = Math.log10(v).to_i / 4
  (1..a).each do |i|
    x = 10 ** (4 * (a-i+1) )
    y = v / x
    print y, k[a-i] if y != 0
    v -= y * x
  end
  print v if v != 0
  puts
end