#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int m,int n){

	int table[76];

	for(int i = 1; i <= 75;i++)table[i] = 0;

	table[2] = m/10;
	table[1] = m%10;

	for(int loop = 0; loop < n-1; loop++){
		for(int i = 1; i <= 74; i++)table[i] *= m;

		for(int i = 1; i <= 74;i++){
			table[i+1] += table[i]/10;
			table[i] %= 10;
		}
	}

	if(1000*table[72] +100*table[71] + 10*table[70] + table[69] != 0){
		printf("%dMts",1000*table[72] +100*table[71] + 10*table[70] + table[69]);
	}

	if(1000*table[68] +100*table[67] + 10*table[66] + table[65] != 0){
		printf("%dFks",1000*table[68] +100*table[67] + 10*table[66] + table[65]);
	}

	if(1000*table[64] +100*table[63] + 10*table[62] + table[61] != 0){
		printf("%dNyt",1000*table[64] +100*table[63] + 10*table[62] + table[61]);
	}

	if(1000*table[60] +100*table[59] + 10*table[58] + table[57] != 0){
		printf("%dAsg",1000*table[60] +100*table[59] + 10*table[58] + table[57]);
	}

	if(1000*table[56] +100*table[55] + 10*table[54] + table[53] != 0){
		printf("%dGgs",1000*table[56] +100*table[55] + 10*table[54] + table[53]);
	}

	if(1000*table[52] +100*table[51] + 10*table[50] + table[49] != 0){
		printf("%dGok",1000*table[52] +100*table[51] + 10*table[50] + table[49]);
	}

	if(1000*table[48] +100*table[47] + 10*table[46] + table[45] != 0){
		printf("%dSai",1000*table[48] +100*table[47] + 10*table[46] + table[45]);
	}

	if(1000*table[44] +100*table[43] + 10*table[42] + table[41] != 0){
		printf("%dSei",1000*table[44] +100*table[43] + 10*table[42] + table[41]);
	}

	if(1000*table[40] +100*table[39] + 10*table[38] + table[37] != 0){
		printf("%dKan",1000*table[40] +100*table[39] + 10*table[38] + table[37]);
	}

	if(1000*table[36] +100*table[35] + 10*table[34] + table[33] != 0){
		printf("%dKo",1000*table[36] +100*table[35] + 10*table[34] + table[33]);
	}

	if(1000*table[32] +100*table[31] + 10*table[30] + table[29] != 0){
		printf("%dJou",1000*table[32] +100*table[31] + 10*table[30] + table[29]);
	}

	if(1000*table[28] +100*table[27] + 10*table[26] + table[25] != 0){
		printf("%dJo",1000*table[28] +100*table[27] + 10*table[26] + table[25]);
	}

	if(1000*table[24] +100*table[23] + 10*table[22] + table[21] != 0){
		printf("%dGai",1000*table[24] +100*table[23] + 10*table[22] + table[21]);
	}

	if(1000*table[20] +100*table[19] + 10*table[18] + table[17] != 0){
		printf("%dKei",1000*table[20] +100*table[19] + 10*table[18] + table[17]);
	}

	if(1000*table[16] +100*table[15] + 10*table[14] + table[13] != 0){
		printf("%dCho",1000*table[16] +100*table[15] + 10*table[14] + table[13]);
	}

	if(1000*table[12] +100*table[11] + 10*table[10] + table[9] != 0){
		printf("%dOku",1000*table[12] +100*table[11] + 10*table[10] + table[9]);
	}

	if(1000*table[8] +100*table[7] + 10*table[6] + table[5] != 0){
		printf("%dMan",1000*table[8] +100*table[7] + 10*table[6] + table[5]);
	}

	if(1000*table[4] +100*table[3] + 10*table[2] + table[1] != 0){
		printf("%d",1000*table[4] +100*table[3] + 10*table[2] + table[1]);
	}

	printf("\n");
}


int main(){

	int m,n;
	while(true){
		scanf("%d %d",&m,&n);
		if(m == 0 && n == 0)break;
		func(m,n);
	}

    return 0;
}

Measured memory_bytes: 2736