import sys def find_largest_divisor(c, d_limit): if d_limit < 1: return 0 max_div = 0 # Check from the minimum of c//2 and d_limit down to 1 start = min(c // 2, d_limit) for candidate in range(start, 0, -1): if c % candidate == 0: max_div = candidate break # If not found, check if c itself is within d_limit, but c > A so c - c = 0 < A return max_div if max_div != 0 else 1 def solve(): input = sys.stdin.read().split() idx = 0 T = int(input[idx]) idx += 1 for _ in range(T): A = int(input[idx]) B = int(input[idx+1]) idx +=2 if A == B: print(0) print() continue steps = [] C = B while C > A: D = C - A # Find largest d that divides C and d <= D d = find_largest_divisor(C, D) steps.append(d) C -= d # Now, reverse the steps to get the addition sequence steps = steps[::-1] print(len(steps)) print(' '.join(map(str, steps))) if __name__ == '__main__': solve()