def METHOD_NAME():
    choice = 0
    segments = []
    while choice != 3:
        print("Menu:")
        print("1. Add segments")
        print("2. Calculate length of union of segments")
        print("3. Exit")
        choice = int(input("Enter your choice: "))
        if choice == 1:
            num_segments = int(input("Enter the number of segments to add: "))
            print("Enter the left and right endpoints of each segment (separated by a space):")
            for _ in range(num_segments):
                left, right = map(int, input().split())
                segments.append((left, right))
            print("Segments added.\n")
        elif choice == 2:
            if not segments:
                print("No segments added.\n")
            else:
                union_length = segment_union_length(segments)
                print("Length of the union of segments:", union_length, "\n")
        elif choice == 3:
            print("Exiting...")
        else:
            print("Invalid choice. Please try again.\n")