const result = []
var mergeKLists = function(array) {
if (array.length === 1) return array
const arrs = []
const map = new Map()
for (let i = 0
const value = array[i][0]
if (value || value === 0) {
arrs.push(value)
map.set(value, i)
} else {
array.splice(i, 1)
}
}
const min = Math.min(...arrs)
const index = map.get(min)
result.push(min)
if (index && array[index]) array[index].shift()
if (array.length === 1 && array[0].length === 0) return result
else if (index && array[index] && array[index].length === 0) array.splice(index, 1)
return mergeKLists(array)
}