Brickgao, who profited from your accurate calculating last year, made a great deal of money by moving bricks. Now he became ``gay shy fool'' again and recently he bought an iphone and was deeply addicted into a cellphone game called Ingress. Now he is faced with a problem so he turns to you for help again. We make some slight modifications based on the original rules, so please draw attention to the details below.
There are $N$ portals (indexed from 1 to $N$) around Brickgao's home, and he can get some substances called XM by hacking the portals. It's known that for each portal $i$, he can get $A_i$ XM during the first hack, and after each hack, the amount of XM he will get during the next hack will decrease by $B_i$. If the amount of XM he can get is less than or equal to zero, Brickgao can't get XM from that portal anymore. For the $i$-th portal, if $A_i = 10, B_i = 2$ and he hacks 3 times, he will get 10, 8, 6 XM during each hack.
There are $M$ bidirectional roads between some pairs of portals and between Brickgao's home and some portals. Now he is eager to start his Ingress journey from home and finally return home, but due to the extremely hot weather, Brickgao will feel sick when you hack more than $K$ times or the distance he covers is more than $L$. So how much XM he can get at most during this journey?