def calc(val,cnt): if cnt==1: return val return calc(N*val,cnt-1) for tc in range(1,10+1): t = int(input()) N,M = map(int,input().split()) res= calc(N,M) print(f'#{t} {res}')