# 貪欲法でWA出たのでビット全探索を考える # math.factorial(20) > 10**18 なので制約で約数の数は20以下 def divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] T = int(input()) for t in range(T): A, B = map(int, input().split()) divs = divisors(A)[::-1] divs_count = len(divs) for bit in range(1<>shift & 1 == 1: d = divs[shift] if B_A >= d: l += (B_A//d) subans.append((d, B_A//d)) B_A -= d*(B_A//d) if l > 120: break if B_A == 0 and l <= 120: break ans = [] for d, c in subans: temp = [d]*c ans.extend(temp) print(len(ans)) print(*ans)