import math n=input() def P(a,b): r=1 while b>0: if b&1==0: a*=a b/=2 else: r*=a b-=1 while a>=10: a/=10. while r>=10: r/=10. return `r`[:3:2] for i in xrange(n): a,b=map(int,raw_input().split()) x,y=P(a,b) print x,y,int(math.log10(a)*b)