def merge_intervals(items):
    if not items:
        return []
    sorted_items = sorted([list(iv) for iv in items], key=lambda x: x[0])
    merged = [list(sorted_items[0])]
    for start, end in sorted_items[1:]:
        if start <= merged[-1][1] + 1:
            merged[-1][1] = max(merged[-1][1], end)
        else:
            merged.append([start, end])
    return merged
