My RBTREES solution is giving TLE

Problem page: RBTREES Problem - CodeChef
TLE Solution link: CodeChef: Practical coding for everyone
I did the exact same thing as given in official editorial but I was getting TLE . Can anyone tell me whats wrong?
I used donor and taker in place of excess and req variables. And ignore the commented lines ( I started with that simple bfs but ended up realizing it could answer only if a solution is possible or not :smile: ). And my dfs function name is solve