BYECAKES - Bye Bye Cakes

no tags 

John is moving to a different city and he wants to use all his perishable food before doing it, to avoid wasting. Luckily all he has now is eggs, flour, sugar and milk, so he is going to make his famous cakes and give them to his friends as a goodbye gift. John only knows how to make an entire cake and not half a cake, a third of a cake, or any other portion. So, he will buy whatever is needed of each ingredient so that he can make an integer number of cakes and have nothing left. Of course, he wants to spend as little money as possible. You must help John to decide how much he should buy of each ingredient.

Input

The input contains several test cases. Each test case is described in a single line that contains eight integers E, F, S, M, E', F', S' and M' separated by single spaces. Values E and E' are numbers of eggs, F and F' are grams of flour, S and S' are grams of sugar, and M and M' are centiliters of milk. For each ingredient, X is the amount John has (0 ≤ X ≤ 1000), while X' is the amount needed to make a single cake (1 ≤ X ≤ 1000). The last line of the input contains the number −1 eight times separated by single spaces and should not be processed as a test case.

Output

For each test case output a single line with four non-negative integers separated by single spaces, representing the amount of each ingredient John needs to buy, in the same order and units as the input.

Example

Input:
2 3 4 5 1 1 1 1
3 6 9 0 1 2 3 4
-1 -1 -1 -1 -1 -1 -1 -1

Output: 3 2 1 0
0 0 0 12

hide comments
pvsmpraveen: 2016-03-27 09:33:04

@ragwave - try ceil( (double)A/B) , you are trying to divide first A/B which gives integer and then asking to ceil, which gives the same integer

nonushikhar: 2016-03-12 18:22:50

my 100th !!!!

ragwave: 2015-12-31 23:31:16

watch out for a/b ..ceil() in c++ didn't work (in my case)!!
answer for 0 0 0 0 1 3 4 5
is 0 0 0 0
happy coding!

Last edit: 2016-01-01 21:42:29
Prateek Agarwal: 2015-12-11 15:16:25

Piece of Cake :)

Kriti Singhal: 2015-08-24 09:50:03

thnxx @jerry.... :D

Babu: 2015-08-19 22:01:39

Thanks @Jerry . @SRC ,souvik try Jerry's test case :P

xceptor: 2015-07-30 21:48:02

take care when you divide :) a/b gives WA

shantanu tripathi: 2015-07-25 20:10:29

this is disgusting!!!!...... if john has no food, milk ...then he will not even buy those thing just only to save money...
just waste of time

Jerry Goyal: 2015-06-30 12:49:11

try this.. 1 1 1 1 2 3 4 5

SangKuan: 2015-06-21 14:59:08

it so bad,waste time


Added by:Pablo Ariel Heiber
Date:2010-08-19
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 VB.NET
Resource:FCEyN UBA ICPC Selection 2008