Tidying the Banquet Tables

No attempts yetTime limit1sMemory limit128 MB

Problem

Korea, Germany, France, and England reached the semifinals of the 2006 World Cup. FIFA held a dinner banquet to celebrate the four teams. Every player and family member came, the hall has 4 tables, and the guests are seated across those tables with no regard for which team they belong to.

The ceremony needs every table to seat the players and families of a single country. Assign the four teams to the four tables one to one, then every guest sitting away from the table assigned to their own team moves to that table. Find how many guests move under the assignment that makes this number as small as possible. Each table has enough seats for a whole team.

Input

Input comes from standard input. The first line contains the number of test cases TT, where 1T51 \le T \le 5.

Each test case consists of 16 integers. The first 4 are the head counts of the Korean, German, French, and English teams at table 1, and the remaining 12 give the per-country head counts at tables 2, 3, and 4 in the same order. The 16 integers of one test case add up to at most 10,000.

Output

Print to standard output. Print exactly one line per test case. Each line holds the minimum number of people who must move so that every table seats the players and families of a single country.