from decimal import Decimal, getcontext getcontext().prec = 100 # Set a high precision to handle very large exponents accurately. ln_10 = Decimal(10).ln() n = int(input()) for _ in range(n): a, b = map(int, input().split()) A = Decimal(a) ln_A = A.ln() log10_A = ln_A / ln_10 log_val = log10_A * b z = log_val // 1 f = log_val - z M = Decimal(10) ** f M_times_10 = M * 10 xy = int(M_times_10) x = xy // 10 y = xy % 10 print(x, y, int(z))