def parse_port_range(port_range_or_num):
    """Parses a port range formatted as 'N', 'N-M', or 'all', where 
    N and M are integers, into a minimum and maximum port tuple."""
    if port_range_or_num.lower() == 'all':
        return 0, 65535
    try:
        port = int(port_range_or_num)
        return port, port
    except ValueError:
        pass
    from_port, to_port = port_range_or_num.split('-', maxsplit=1)
    return int(from_port), int(to_port)