from typing import Tuple
from typing import List
import re


def get_ranges_and_departures(
    header: str,
) -> Tuple[List[List[Tuple[int, int]]], List[int]]:
    """
    Parse the header of the incoming data. It's formatted as::

        name: #-#[ or #-# [...]]

    Return the list of tuples of ranges formatted as [[(#, #), (#, #)], ...]
    and the list of row indices that start with the word 'departure' for Part 2
    """
    ranges = []
    departure_lines = []

    for i, line in enumerate(header.split("\n")):
        if line.startswith("departure"):
            departure_lines.append(i)
        raw_ranges = re.findall(r"(\d+)", line)
        ranges.append(
            [
                (int(left), int(right))
                for left, right in zip(raw_ranges[::2], raw_ranges[1::2])
            ]
        )

    return ranges, departure_lines