ALORA3 - NZEC with Python

I am facing a problem with the Prisoner of Azkaban problem. This is my solution. It has been written in Python 3.x . Its getting NZEC. Can anyone point out where am I going wrong? The weird part is that it has no solutions in Python. SO can’t really figure it out. Any Test cases or any hint would be highly appreciated. Thanks in advance