#include <iostream>
#include <algorithm>
using namespace std;

unsigned int gcd(unsigned int u, unsigned int v)
{
    // simple cases (termination)
    if (u == v)
        return u;
 
    if (u == 0)
        return v;
 
    if (v == 0)
        return u;
 
    // look for factors of 2
    if (~u & 1) // u is even
    {
        if (v & 1) // v is odd
            return gcd(u >> 1, v);
        else // both u and v are even
            return gcd(u >> 1, v >> 1) << 1;
    }
 
    if (~v & 1) // u is odd, v is even
        return gcd(u, v >> 1);
 
    // reduce larger argument
    if (u > v)
        return gcd((u - v) >> 1, v);
 
    return gcd((v - u) >> 1, u);
}

int main() {
	int t, n, arr[50], cmmn, yes;
	cin>>t; 
	while(t--) {
		cin>>n;
		for(int i=0; i<n; i++) cin>>arr[i];
		cmmn=1005; yes=1;
		for(int i=1; i<n; i++) if(gcd(arr[0], arr[i])<cmmn) cmmn=gcd(arr[0], arr[i]);
		for(int i=0; i<n; i++) if(cmmn!=arr[i]) yes=0;
		if(yes) for(int i=0; i<n; i++) cout<<1<<" ";
		else if(cmmn==1) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
		else for(int i=0; i<n; i++) cout<<(arr[i]/cmmn)<<" ";
		cout<<endl;
	}
	return 0;
}