#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        long long int a[n];
        long long int sum=0,sum1=0;
        for (int i = 0; i < n; i++) {
            cin>>a[i];
            if(i%2==0)
            {
                sum+=a[i];
            }
            else
            {
                sum1+=a[i];
            }
            
        }
        
        if(sum1>sum)
        {
            for (int i = 0; i < n; i++) {
                if(i%2==0)
                {
                    a[i]=1;
                }
            }
        }
        else
        {
            for (int i = 0; i < n; i++) {
                if(i%2!=0)
                {
                    a[i]=1;
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
	return 0;
}
