def check_pairwise(a, func):
    """
    Check whether a condition (computed by `func`) holds pairwise for elements
    in the sequence `a`. Assumes `func` is symmetric for the two operands.
    """
    if len(a) < 2:
        return True
    for i, x in enumerate(a, 1):
        for y in a[i:]:
            if not func(x, y):
                return False
    return True
