407104: GYM102697 075 Shopping Spree

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

075. Shopping Spreetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You've been selected to be the recipient of Wegman's shopping spree program! The only caveat is that you have to be continuously moving through the building at all times, through the different sections in a circular pattern, so you will only have time to grab one item from each section. It will also take some time for you to move to the different locations of the store, and luckily, this Wegmans only has 3 sections, as the architect designing this location was lazy with his design.

Produce –> Meat Meat –> Dry Goods Dry Goods –> Produce

You want to know how many loops it will take you to get a certain amount of different types of items.

Input

The first line will contain an integer $$$n$$$, which denotes the amount of test cases that will follow. These test cases will each contain 3 different, space-separated integers denoting the amount of different items you will need to complete the shopping list.

The first line will always be Produce $$$p$$$, the second will be Meat $$$m$$$, and the third will be dry goods $$$d$$$.

Output

Return the amount of loops it will take for you to complete your shopping list.

ExampleInput
3
2 6 1
3 2 1
1 5 7
Output
6
3
7

加入题单

上一题 下一题 算法标签: