def interval_intersect(int1, int2):
    """Given two two-long sequences representing closed intervals, return
    their intersection.  Input or output may be None, indicating an
    empty interval.

    """
    if int1 is not None and int2 is not None:
        mi, ma = max(int1[0], int2[0]), min(int1[1], int2[1])
        if mi <= ma:
            return mi, ma
    return None