Merge sorted lists using a priority queue.