for b in genB:
    while next_a < b:
        saved_a.append(next_a)
next_a = next(genA)
for a in saved_a:
    heapq.heappush(heap, (a + b, a, b))
while heap and heap[0][0] <= b + a0:
    yield heapq.heappop(heap)[1:]
Generate ordered tuples of infinite sequences