n = int(input()) for i in range(n): a, b = map(int, input().split()) s = str(a ** b) a, b = s[0], s[1] if len(s) > 1 else 0 print(a, b, len(s) - 1)