Limits 2s, 512 MB

Jony lives in a "Bachelor's house" with some of his friends. You may assume it as a hostel but it doesn't operate as a hostel. To lead a life in a hostel is so much tough. They have to pay so many different bills in every month along with everyday marketing. There is a manager to whom everyone pays their bills in advance every month. There are six types of bills they have to pay, like House Rent, Meal, Internet Bill, Maid Bill, Electricity Bill, and Garbage Bill. As Jony has to pay all of his bills in advance so he has to fix a budget for him every month. He always gets confused to determine his budget as there are some issues. Help him out!

Note that, if current month's budget is less than current month's bill
then he has to pay the remaining bills with next month's bill.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases. Each case contains six integers n1, n2..........n6 (1<=n<=2000) denoting House Rent, Meal, Internet Bill, Maid Bill, Electricity Bill, and Garbage Bill of current month. Next line contains one integer B (1<=B<=10000) denoting current month's budget. Again it will take six integers m1, m2 ....... m6 (1<=m<=2000), denoting next month's bills.

Output

For each case print case number in the first line. Then print next month's budget. Follow sample input output for better understanding.

Sample

InputOutput
1
2000 1500 300 280 200 100
5000
2000 1700 300 230 200 100
Case 1: 3910

For the first case, total expense of the current month is 2000+1500+ 300+280+200+100 = 4380 Tk.

As his budget is 5000 Tk, so the next month's budget will be (2000+1700+300+230+200+100) - (5000-4380) = 3910 Tk.

Submit

Login to submit.

Statistics

73% Solution Ratio
AnikaTahsinEarliest, Dec '16
AnikaTahsinFastest, 0.0s
Nasif_44thLightest, 0 B
Nusab19Shortest, 114B
Toph uses cookies. By continuing you agree to our Cookie Policy.