k = %[Man Oku Cho Kei Gai Jo Jou Ko Kan Sei Sai Gok Ggs Asg Nyt Fks Mts].split.to_a
k.unshift("")
while gets
  m, n = $_.split.map(&:to_i)
  break if m == 0 && n == 0
  v = m ** n
  x = []
  a = v.to_s.size / 4
  0.upto(a){ |i| x[i] = v / 10**(4*i) % 10000 }
  a.downto(0){ |i| print x[i], k[i] if x[i] > 0 }
  puts
end