Time limit
1s
Memory limit
128 MB
Eunju wants to make as many pancakes as possible from the ingredients she has.
Each pancake needs one piece of batter before it can be cooked. 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 pieces of pancake batter. For any real number x >= 0, if every basic ingredient she has is at least x times the amount above, then she can make ⌊16x⌋ pieces of batter.
One piece of batter becomes one pancake by adding exactly one of the topping combinations below and cooking it.
Bananas may be split into pieces or combined from pieces. For example, three 1/3-banana pieces can be combined to make one banana pancake.
For each test case, find the maximum number of pancakes Eunju can make.
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 mean Eunju has cm cups of milk, y egg yolks, ssu spoons of sugar, ssa spoons of salt, and f cups of flour.
The second line contains four integers b, gs, gc, and w. They mean Eunju has b bananas, gs grams of strawberry jam, gc grams of chocolate spread, and w walnuts.
Every amount is an integer 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.