
    Given a list of bus route segments where each segment is represented as a tuple containing origin and destination stops, write a function to count how many pairs of stops have bus service running in both directions. A bidirectional service exists when there are two segments connecting the same stops in opposite directions (e.g., Stop A to Stop B and Stop B to Stop A).
    

    
def count_bidirectional(test_list):
    """
    Given a list of bus route segments where each segment is represented as a tuple containing origin and destination stops, write a function to count how many pairs of stops have bus service running in both directions. A bidirectional service exists when there are two segments connecting the same stops in opposite directions (e.g., Stop A to Stop B and Stop B to Stop A).
    

    """
def count_bidirectional(test_list):
    """
    Given a list of bus route segments where each segment is represented as a tuple containing origin and destination stops, write a function to count how many pairs of stops have bus service running in both directions. A bidirectional service exists when there are two segments connecting the same stops in opposite directions (e.g., Stop A to Stop B and Stop B to Stop A).
    

    """
    res = 0
    for idx in range(0, len(test_list)):
        for iidx in range(idx + 1, len(test_list)):
            if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
                res += 1
    return res