Original post location [http://acm.tongji.edu.cn/people/ps/showproblem.php?problem_id=1000&conte_id=6] qublem
In order to save Athena, Axus, Zilong, Ice, and Axi, you must have a golden tweet palace.
This question includes multi-group data, 5 lines per group. Chain 1, S1, S2, S3, S4 (1 <= S1, S2, S3, S4 <= 20) Chain 2, for A1 ... AS1 S1, indicating the extent of each damage to the first hunger, that is, Mr. Mu fixes the time it takes to the third line, which is B1 ... BS2 total S2, indicating that the second holy clothing The extent of a broken loss is that Mr. Mu fixes the fourth line of the time it used, which is C1 ... CS3 a total of S3, indicating the extent of each damage to the third holy cloth, which is Mr. Mr. The time used, the number of D1 ... DS4 has a total of S4, indicating the extent of each damage to the fourth holy cloth, which is the time used by M.
For each group of data outputs,
1 2 1 3
5
4 3
6
2 4 3
Sample Output
20
First of all, they came to the Aries, as Mr. Mu, who was Aries Golden Saint Seiyou, I have long known that the fake pope's conspiracy, so he decided to help Starians. Mr. Mu has found that four of them have several battles, and they have more broken clothes. If you continue to challenge Golden Saint Soldiers, you will definitely. It is necessary to help the star to repair their holy clothes.
It is now known that there are several broken clothes (S1, S2, S3, S4), and each is different, the degree of damage is more, Mr. Mu takes more time to repair it. The degree of damage is used by Mr. Mu to repair it (A1 ... AS1, B1 ... BS2, C1 ... CS3, D1 ... DS4). However, Mr. Mu is very strong and can be repaired at the same time. But this is damaged, which can only be on the same holy clothing. That is to say, he can only fix a holy dress at the same time, fix it, in order to fix the next piece.
INPUT
(1 <= a1 ... AS1, B1 ... BS2, C1 ... CS3, D1 ... DS4 <= 60)
OUTPUT
Mr. Mu fixes the shortest time you want four holy clothes. (Description of Sample Output: 5 4 6 (2 3) = 20)
Sample Input