from typing import Sequence


def timestamp_to_ms(groups: Sequence[str]):
    """
    Convert groups from :data:`pysubs2.time.TIMESTAMP` match to milliseconds.
    
    Example:
        >>> timestamp_to_ms(TIMESTAMP.match("0:00:00.42").groups())
        420
    
    """
    h, m, s, frac = map(int, groups)
    ms = frac * 10**(3 - len(groups[-1]))
    ms += s * 1000
    ms += m * 60000
    ms += h * 3600000
    return ms