提示: 欢迎访问OurACM平台。
Problem 1814 Brain Pain

Accept: 11    Submit: 15
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Brain Pain is a math game played with three sets of four cards. Only the cards from one (ace) to ten are used. The goal of the game is to find the highest number that can be made on each of the three sets of cards, using all four cards in each set, and with basic operations only. By basic operations, I mean addition, subtraction, multiplication and division (and parentheses). Note that the maximum need not be an integer.

Input

The first line of input consists of the number of test cases T ≤ 100 on a line by itself. Each of the next T lines will contain 12 white space separated integers between 1 and 10 (inclusive). The first four are the four cards of the first set, the next four are the four cards of the second set, and the last four are the four cards of the third set.

Output

For each test case, print the value of the highest number that can be formed on all three sets of four cards on a line by itself.

Sample Input

1 1 4 7 10 2 4 6 8 3 4 5 6

Sample Output

84

Source

2008-2009 North-America North-East Preliminary

Submit  Back  Status  Discuss