import sys def input(): return sys.stdin.buffer.readline()[:-1] for _ in range(int(input())): a, b = map(int, input().split()) res = [] l = b.bit_length() for i in range(l-1, -1, -1): if (a >> i) & 1 != (b >> i) & 1: lim = i break for i in range(lim): if (a >> i) & 1: res.append(1 << i) a += (1 << i) for i in range(lim, -1, -1): if (b >> i) & 1 == 1 and (a >> i) & 1 == 0: res.append(1 << i) print(len(res)) print(*res)