import heapq as p;

class Solution(object):

```
def mergeKLists(self, lists):
heap = []
for i in range(len(lists)):
if lists[i]:
p.heappush(heap, (lists[i].val, i))
lists[i] = lists[i].next
ret = cur = ListNode(-1)
while heap:
n_val, i = p.heappop(heap)
cur.next = ListNode(n_val)
if lists[i]:
p.heappush(heap, (lists[i].val, i))
lists[i] = lists[i].next
cur = cur.next
return ret.next
```