Issue with code submission for problem code : CNOTE

I have two solutions listed below for problem :

AC :
WA :

Bot the solutions are identical except for one thing :
If i try to break the inner loop if a suitable notebook is found then the solution is stated as Wrong.
I am not able to understand why is this happening.
As per the problem statement, if a suitable notebook is found it should be good enough. I don’t see why we need to iterate through all the notebooks.
Can someone please help with what i am missing here ?