NZEC Error in python3

So I was solving Digit Longest Increasing Subsequences 2 problem (LISDIGIT). And this is my submission here. It’s a bit lengthy, but I’m sure that I have included all the constraints as requested and even used stdin and stdout for I/O. With all of that said and done, I still bumped into NZEC error.

Please look over my code and tell me what the problem is.

Thank you

//