I had a doubt how this solution clears large dataset of Kickstart Round B as it is (N*M*K) which is dp entries and each entry is computed in approx (N*M). Lastly T test cases too and each of the variable, that is, N, M, K, T is in range 1,..,100.
Am I making an error in understanding or test cases were weak as I tried locally on large dataset and it worked within 2 mins.