from decimal import Decimal, getcontext, ROUND_DOWN getcontext().prec = 50 # Precision for logarithm calculations def compute_values(a, b): log_a = Decimal(a).ln() / Decimal(10).ln() log_ab = log_a * b m = int(log_ab) f = log_ab - m # Calculate 10^f with adjusted precision for efficiency getcontext().prec = 20 t = (10 ** f).quantize(Decimal('1.0'), rounding=ROUND_DOWN) x = int(t) y = int((t - x) * 10) return x, y, m n = int(input()) for _ in range(n): a, b = map(int, input().split()) x, y, z = compute_values(a, b) print(x, y, z)