t = int(input()) from collections import deque import math for _ in range(t): a,b = map(int,input().split()) l = [] r = [] for i in range(120): if a == b: break g = math.gcd(a, b) if (a//g)%2 == 1: l.append(g) a += g if (b//g)%2 == 1: r.append(g) b -= g r.reverse() ans = l+r print(len(ans)) print(*ans)