Juice Blend

For each test case, choose integer shares of three juices summing to 10000 so that the most guests get at least their per-juice minimums.

Medium7GeometryImplementationBrute forceGreedyNo attempts yetTime limit5sMemory limit512 MB

Problem

You are throwing a party, and you mix three juices into one drink: apple, banana and carrot. Call them juice A, juice B and juice C.

You decide what share of the drink each juice takes. A share is an integer in parts per ten thousand, and the three shares add up to exactly 1000010000.

Each guest has a minimum share for every juice. A guest likes the drink only if the share of each of the three juices is at least that guest's minimum for that juice.

Choose the shares so that as many guests as possible like the drink, and report that number.

Input

The first line contains an integer T, the number of test cases.

Each test case is given as follows.

  • One line with the integer N, the number of guests at the party.
  • N lines, one per guest, each with three space-separated integers "A B C", the minimum share that guest wants of each juice, in parts per ten thousand. They satisfy 0A,B,C100000 \le A, B, C \le 10000 and A+B+C10000A + B + C \le 10000.

Limits

  • 1T121 \le T \le 12
  • 1N50001 \le N \le 5000

Output

Print one line per test case, in the order the test cases appear in the input, containing "Case #X: Y". X is the test case number starting from 11, and Y is the largest number of guests who like the drink.

Hint

In the first test case of the first example, each of the three guests wants the drink made from a single juice, and the three juices differ, so only one guest can be satisfied.

In the second test case, any two of the three guests can be satisfied together.

In the third test case, shares of 33343334, 33333333 and 33333333 satisfy all five guests.