Run Error in Last TestCase

while(k>0&&l>0)
this is complete while loop entry condition

you have not included l>0
this is also important otherwise you will get runtime error