n = int(input()) from math import log from bisect import bisect_left res = [-1.0] + [log(i/10,10) for i in range(1,101)] for _ in range(n): a,b = map(int,input().split()) c = b*log(a,10) z = int(c) idx = bisect_left(res, c-z) - 1 if idx <= 9: idx = 10 if idx >= 100: idx = 99 x = idx//10 y = idx%10 print(x,y,z)