#include<bits/stdc++.h> 
using namespace std;
void solve()
{
	long long int n,s=0,sum=0,k;
	cin>>n;
	long long int arr[n+1];
	for(int i=1;i<=n;i++)
	{
	cin>>arr[i];
	if(i%2==1)
	sum=sum+arr[i];
	else
	s=s+arr[i];}
	if(sum>=s)
	{
		for(int i=1;i<=n;i++)
	    {
	    	if(i%2==1)
	    	cout<<arr[i]<<" ";
	    	else
	    	cout<<"1"<<" ";
		}
	}	
	else
	{
		for(int i=1;i<=n;i++)
	    {
	    	if(i%2==0)
	    	cout<<arr[i]<<" ";
	    	else
	    	cout<<"1"<<" ";
		}
	}
		cout<<endl;
}
int main() {
	int t=1;
	cin >> t;
	while(t--) {
		solve();
	}
}

