def is_order_constrained(paths, constraints, j, k):
    """Is the order of the sequences between j and k constrained. Such that reversing this order will violate
    the constraints."""
    for q in range(j, k):
        # search between j and k.
        first_path = paths[q]
        for constraint in constraints:
            if first_path is not constraint[0]:
                # Constraint does not apply to the value at q.
                continue
            for m in range(q + 1, k):
                second_path = paths[m]
                if second_path is constraint[1]:
                    # Constraint demands the order must be first_path then second_path.
                    return True
    return False