from decimal import Decimal, getcontext, ROUND_DOWN getcontext().prec = 1000 # High precision to handle large exponents def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 for _ in range(N): A = int(input[idx]) B = int(input[idx + 1]) idx += 2 # Calculate log10(A) using natural logarithm for higher precision logA = Decimal(A).ln() / Decimal(10).ln() total = B * logA # Extract integer part (k) and fractional part (f) k = int(total) f = total - k # Compute 10^f with high precision and truncate to first decimal place ten_f = (Decimal(10) ** f).quantize(Decimal('0.1'), rounding=ROUND_DOWN) # Convert to string to extract X and Y s = format(ten_f, 'f') if '.' in s: int_part, frac_part = s.split('.') else: int_part = s frac_part = '0' X = int(int_part[0]) Y = int(frac_part[0]) if len(frac_part) > 0 else 0 Z = k print(f"{X} {Y} {Z}") if __name__ == "__main__": main()