luogu#P10823. [EC Final 2020] Prof. Pang Earning Aus
[EC Final 2020] Prof. Pang Earning Aus
题目描述
Prof. Pang has only Au in his pocket. (Yes, Prof. Pang is from Austan and he uses the currency Au there.)
He will make use of a balloon store and a candy store to make money: In the balloon store, Prof. Pang can buy balloons for the price of Au or buy balloons for the price of candy. In the candy store, Prof. Pang can buy candies for the price of Au or buy candies for the price of balloon. Prof. Pang can also sell one balloon and get Aus. He can sell one candy and get Aus. The only constraint to him is that there are only balloons in the balloon store and only candies in the candy store. He can buy balloons and candies only when supplies last. Even if he sells some of his balloons or candies, the number of balloons and candies in the stores will not increase.
Each of the six transactions can be performed in any order for any times ( or more) but they are not separable (for example, Prof. Pang can not buy balloons for the price of Au).
Please find out how many Aus he can make at most.
输入格式
The first line contains a single integer () denoting the number of test cases.
Each of the next lines contains eight integers , , , , , , , (, $1\le k_{ab}, k_{ba}, k_{ac}, k_{ca}, k_{bc}, k_{cb}\le 100$) separated by single spaces.
输出格式
For each test case, print one line containing the answer.
6
2 2 2 2 2 2 2 2
78 74 5 3 10 2 4 7
31 75 3 6 6 1 8 4
91 86 4 2 9 5 8 5
48 89 3 9 2 3 5 7
13 25 5 7 6 1 2 4
7
355
239
571
637
109
提示
In the first example, Prof. Pang buys balloons with Au and then sells balloons and gets Aus. Then he buys candies with Au, sells candies and gets Aus.