PepperLa is a braggart(King of Blowing Cattle), which only means he has great lung capacity.
One day,the two-dimensional plane he lives is on fire.His current position is $(1,1)$, and the fire escape is at $(n,m)$. "Just a fire, why bother!" PepperLa boasted.
Because the fire is spreading quickly, once he starts running, he can't turn back. If his current position is $(x, y)$, he can only move forward to $(x+1,y+1)$ or $(x+1,y)$ or $(x,y+1)$ in one minute.
There is different volume of fresh air rested in each area. If an area's fresh air $\leq 0$, that means what left in the area is poisonous somke, PepperLa couldn't breath here.
Thanks to PepperLa's great lung capacity, each breath he can take in any volume of air and stored in his lung, he can hold the breath through poisonous smoke area. Each time, He can hold his breath for at most $K$ minutes, and cost $U$ volume of air.(If he doesn't hold the breath it cost no air, wow) He can start to hold his breath only if the air in his lung $>= U$.
Now PepperLa wonder whether he could survive so he could brag about his heroic experience. If PepperLa survives, he wants to know the maximum volume of air left in the lung when he comes to the exit.(the more air left, the more he can boast) If PepperLa couldn't escape, sadly, output -1.