u=["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"];
[*$<][0..-2].map{|s|n,m=s.split.map &:to_i;a=n**m;
ans="";
u.size.times{|i|if a%10000>0;ans=(a%10000).to_s+u[i]+ans;end;a/=10000}
puts ans
}
