why i am getting runtime error(NZEC)

this is my code…

The problem is with line 3 and line 4. You wrote:


This will not work, because n and m are space separated(not newline separated) and the first input() takes both of them as a whole string. This gives the error:

ValueError: invalid literal for int() with base 10: '3 3'

when tried with first two lines of the given test case on the problem page.

To get rid of this, try this instead of those lines:


This will split the string “3 3” as “3” and “3” and convert them to int and finally assign them to n and m respectively.

1 Like