Problem: The chef has a recipe he wishes to use for his guests,
but the recipe will make far more food than he can serve to the guests.
The chef therefore would like to make a reduced version of the recipe which has the same ratios of ingredients, but makes less food.
The chef, however, does not like fractions.
The original recipe contains only whole numbers of ingredients,
and the chef wants the reduced recipe to only contain whole numbers of ingredients as well.
Help the chef determine how much of each ingredient to use in order to make as little food as possible.

Input
Input will begin with an integer T, the number of test cases.
Each test case consists of a single line.
The line begins with a positive integer N, the number of ingredients.
N integers follow, each indicating the quantity of a particular ingredient that is used.

Output
For each test case, output exactly N space-separated integers on a line,
giving the quantity of each ingredient that the chef should use in order to make as little food as possible.

Sample Input
3
2 4 4
3 2 3 4
4 3 15 9 6


Sample Output
1 1
2 3 4
1 5 3 2


Constraints
T≤100
2≤N≤50
All ingredient quantities are between 1 and 1000, inclusive.

Solution (in PYTHON):

Solution:
#Cutting Recipes

def HCF(lis, num):
    for i in reversed(range(1,num+1)):
        if num%i == 0 and factor(lis, int(i)):
            return i

def factor(lis, hcf):
    for i in lis:
        if int(i)%int(hcf) != 0:
            return  False
    return True

def accord(lis):
    less = 0
    for i in range(0, len(lis)-1):
        if lis[i] > lis[i+1]:
            less = int(lis[i+1])
        elif lis[i] < lis[i+1]:
            less = int(lis[i])
        else:
            less = int(lis[i])
    return less

def reducer(lis):
    new_lis = []
    n = len(lis)
    nlis = int(accord(lis))
    fact = HCF(lis, int(nlis))
    for i in lis:
        new_lis.append(int(int(i)/int(fact)))
    return new_lis

def main():
    T = raw_input()
    T = int(T)
    while(T!=0):
        lis = []
        res = []
        N = raw_input().split()
        n = int(N[0])
        for i in range(1, n+1):
            lis.append(N[i])
        res = reducer(lis)
        st = ''
        for i in range(0, n):
            st += str(res[i]) + " "
        print st
        T-=1

if __name__ == '__main__':
    main()