Ensure that you are logged in and have the required permissions to access the test.
Rajeev is on a diet plan. He likes junk foods very much.
Rajeev is given a sequence containing N foods packets to eat. Every packet contains two items out of which he can eat only one. One item is healthy and the other one is a junk food. On eating healthy item, his energy increases by packet[i] but on eating the junk item his energy decreases by packet[i].
Initially Rajeev has E amount of enery in his body. If at any stage Rajeev has energy less than 0, he will die. Also, his body can retain only M amount of maximum energy. So, in this case too he will die.
Print the maximum energy rajeev can have after eating N packets. If there is no way to go through the list without exceeding M or going below 0, print -1.
NOTE: You cannot skip any packet.
N -the number of food packets.
E - the initial energy.
M - the Maximum energy
packet[i] - energy of ith packet that can be gained or lost
Input:
First line of input contains T denoting the number of testcases
Each test case contains two lines.
First line of each test case contains N, E, M.
Second line of each test case contains N numbers denoting the energy of ith packet.
Output:
For each testcase print your answer in a separate line.
Constraints:
1<=T<=300
1 <= N <= 50
1 <= packet[i] <= M.
1 <= M <= 1000.
0 <= E <= 1000
Problem Setter:
Shikhar Kunal