def solve(a, b):
    res = []
    while a.bit_length() == b.bit_length():
        base = 1 << (a.bit_length() - 1)
        a -= base
        b -= base
    
    if a:
        while a.bit_length() != b.bit_length():
            add = ((a-1)&a)^a
            res.append(add)
            a += add
        base = 1 << (a.bit_length() - 1)
        b -= base
    
    
    while b:
        add = 1 << (b.bit_length() - 1)
        res.append(add)
        b -= add
    return res


def check(a, b, res):
    for r in res:
        if a % r:
            print('NG Case 1')
            return False
        a += r
    if a == b:
        return True
    else:
        print('NG Case 2')
        return False

T = int(input())
for _ in range(T):
    a, b = map(int, input().split())
    res = solve(a, b)
    # print(check(a, b, res))
    print(len(res))
    print(*res)