Give an O(n log k) algorithm that merges k sorted lists with a total of n elements into one sorted list.