The challenge is to find the bridges. The algorithm is based on recursion. Up to 10,000 items, everything works fine. But, if more, then the stack is full.
threading.stack_size(67108864) thread = threading.Thread(target=main) thread.start() I found this in the internet. It helped, but now it began to deduce some extra numbers, and figures that are generally beyond the limit of a possible answer.
If you simply increase the sys.setrecursionlimit(2**20) to max size does not help. But if you write 3 lines (which are thread), then the program at least works. But both correct answers and incorrect ones are displayed.