def parse_byte_ranges(s):
    """Parses strings like "1,3-5" into set(1,3,4,5)."""
    result = set()
    for term in s.split(","):
        parts = [int(p) for p in term.split("-")]
        if len(parts) == 1:
            hi = parts[0]
            lo = parts[0]
        elif len(parts) == 2:
            lo, hi = min(parts), max(parts)
        else:
            raise ValueError(
                f"""Couldn't parse "{term}" as byte or as a range of bytes"""
            )
        if lo < 0:
            raise ValueError(f"Value out of range: {lo}")
        elif hi > 255:
            raise ValueError(f"Value out of range: {hi}")
        result.update(range(lo, hi + 1))
    return result