def canonise(i, j):
    """ Return canonical intervals of the input interval.

    Args:
        i (int): left endpoint of input interval (inclusive).
        j (int): right endpoint of input interval (inclusive).

    Returns:
        List of canonical intervals. Each interval is of the form (start,end)
        where start and end are integers.
    """

    if j-i <= 8:
        return []
    retval = []
    retval.append((i, j))
    midpoint = (i + j)/2
    retval.extend(canonise(i, midpoint))
    retval.extend(canonise(midpoint + 1, j))
    return retval