Why am i getting key error?

dp - tilling problem (n*m)
my code is giving correct answer for small N and M - upto --less than 1000. after that it is giving key error.
here i apply recursion and use dictionary for memoization.

bhai thora aram kr lo yaar:wink::blush: