import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class CuttingRecipes {
public static void main(String args[]) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out));
int n=Integer.parseInt(br.readLine());
for(int i=0;i<n;i++)
{
String[] s=br.readLine().split(" ");
int length=Integer.parseInt(s[0]);
int[] a=new int[s.length-1];
String opIfDivisible="",opIfNotDivisible="";
for(int j=1;j<s.length;j++){
a[j-1]=Integer.parseInt(s[j]);
}
int min=minimum(a);
int count=0;
for(int j=0;j<a.length;j++){
if(a[j]%min==0){
opIfDivisible+=a[j]/min+" ";
count++;
}
}
for(int j:a){
opIfNotDivisible+=j+" ";
}
if(count==length)
{
out.println(opIfDivisible.trim());
}
else
{
out.println(opIfNotDivisible.trim());
}
}
out.close();
}
private static int minimum(int[] a) {
int min=a[0];
for(int i=0;i<a.length;i++)
{
if(a[i]<min)
min=a[i];
}
return min;
}
}