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