def demand_crosses_cut(demand, cut):
    """
    Determines whether a demand crosses a cut.
    :param demand: tuple of indices of the demand
    :param cut: tuple of indices of the cut
    :return: whether the given demand crosses the given cut
    """
    i, j = min(demand), max(demand)
    g, h = min(cut), max(cut)
    return (i <= g < j <= h) or (g < i <= h < j)