def all_segments(N):
    """
    Return (start, end) pairs of indexes that orm segments of tour of length N

    """
    return [(start, start + length)
            for length in range(N, 2-1, -1)
            for start in range(N - length + 1)]