Help for e-olymp problem-5852

The problem is much more difficult than I thought. Now, even I think that there is some problem with our “tunnel condition”. Maybe, someone else will be able to help us. As of now, I am giving up on this problem. Do share the solution if you get.

Yaa sure!!