N = input() for i in range(N): a,b = map(int, raw_input().split()) c = map(str, str(a ** b)) print c[0],c[1],len(c) - 1