def is_valid(ticket, rules):
    """
    Check if a ticket is valid by checking if all numbers on the ticket match at least one rule
    - outer all: all numbers must match at least one rule
    - middle any: number must match at least one of the rules e.g. "seat" or "class"
    - inner any: number must match at least one of the ranges of the rule e.g. 1-3
    :param ticket: list of ticket numbers to check
    :param rules: dictionary of rules (a rule is a list of two tuples, each tuple is a low and a high range number)
    :return: True if the ticket is valid, i.e. all numbers match at least one rule
    """
    return all(
        any(
            any(
                low <= n <= hi for low, hi in v
            )
            for v in rules.values()
        )
        for n in ticket
    )