So you may not know that there is a Python subforum that should be used for Python specific questions:
https://www.spoj.pl/forum/viewforum.php?f=20
Indeed, input differs from the specification noted in the problem description, but empty lines do not occur.
And: Yes, your code gives NZEC because of mishandling of input data.
But: If you correct this, your code will result in WA because of another problem.
Nevertheless you should remove your code as it gives too much away.
If code is removed, I'll give you two hints on how to get AC.