Back

Cooking

Worth 3 point(s) - Runtime Limit: 1 seconds

Introduction

It’s time to bake some cookies for the holidays. You have a cookie recipe that bakes 22 cookies. It requires 3 cups of flour, 2 eggs, 2 cups of milk, and 1 cup of sugar to make the batch. Given this recipe and the amount of each ingredient that you possess, compute the maximum number of full-sized cookies that can be baked.

Input

The first line of input will contain an integer T denoting the number of test cases to follow. For each test case, there will be four space-separated integers, F, E, M, and S, giving the amount of each ingredient that you have. F gives the number of cups of flour, E the number of eggs, M the number of cups of milk, and S the number of cups of sugar.

2
7 4 3 6
2 2 3 2

Output

For each test case, output a line containing the maximum number of cookies that can be baked. Note that you will not be baking in any sort of batches but that you will be adjusting the recipe to maximize your cookie output.

33
14