from decimal import Decimal, getcontext, ROUND_FLOOR
import sys

getcontext().prec = 50  # High precision to handle large exponents

def compute_case(A, B):
    log_A = Decimal(A).ln() / Decimal(10).ln()  # log10(A)
    log_val = B * log_A
    z = int(log_val)
    f = log_val - z  # fractional part

    x_y = 10 ** f
    # Truncate to one decimal place
    rounded_xy = x_y.quantize(Decimal('0.1'), rounding=ROUND_FLOOR)
    X = int(rounded_xy)
    
    # Extract Y from the truncated decimal
    str_xy = format(rounded_xy, 'f')  # Avoid scientific notation
    if '.' in str_xy:
        _, decimal_part = str_xy.split('.')
        decimal_part = decimal_part.ljust(1, '0')  # Ensure at least one digit
    else:
        decimal_part = '0'
    Y = int(decimal_part[0])
    
    Z = z
    return X, Y, Z

def main():
    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
        X, Y, Z = compute_case(A, B)
        print(f"{X} {Y} {Z}")

if __name__ == '__main__':
    main()