Time limit
1s
Memory limit
128 MB
Eunju wants to make pancakes. Given the amounts of ingredients she has, find the maximum number of pancakes she can make.
Before making pancakes, she must prepare batter. With 8 cups of milk, 8 egg yolks, 4 spoons of sugar, 1 spoon of salt, and 9 cups of flour, she can make 16 portions of pancake batter. For any real number x at least 0, if every ingredient is available in at least x times the listed amount, then she can make (\lfloor 16x \rfloor) portions of batter.
After adding toppings to batter and baking it, a pancake is complete. The available pancake types and their required toppings are as follows.
Bananas may be split into pieces or combined from pieces. For instance, three banana pieces of size 1/3 can be combined and used as one banana.
Print the maximum number of pancakes Eunju can make with her ingredients.
The first line contains the number of test cases T. Test cases may be separated by blank lines, and each test case consists of two lines.
The first line of each test case contains five integers cm, y, ssu, ssa, and f. They are the number of cups of milk, egg yolks, spoons of sugar, spoons of salt, and cups of flour Eunju has, respectively.
The second line contains four integers b, gs, gc, and w. They are the number of bananas, grams of strawberry jam, grams of chocolate spread, and walnuts Eunju has, respectively.
All given amounts are integers between 0 and (10^6), inclusive.
For each test case, output one integer on its own line: the maximum number of pancakes Eunju can make.
In the first visible test, she can make 10 banana pancakes, 1 strawberry pancake, 4 chocolate pancakes, and 1 walnut pancake.
In the second visible test, the amount of flour allows 30 portions of batter, so both the toppings and the batter allow up to 30 pancakes.