I am trying to solve this 1234C - Трубы.
In the 5th test case, i am getting a max recursion limit exceeded error 88052124. I have tried setting the sys.setrecursionlimit and also tried solving it with C++ 88047895, and still getting the same issue. I tried generating a lot of random test cases locally to test it, however everytime it runs succesfully.
Can anyone suggest me what I am doing wrong or provide a example where my code will fail.