#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    ll odd=0,even=0;
    for(int i=0; i<n ; i++)
    {
        cin>>a[i];
        if(i%2==0) even+=a[i];
        else odd+=a[i];
    }
    if(even>=odd)
    {
        for(int i=0; i<n ; i++)
        {
            if(i%2==0)
                printf("%d ",a[i]);
            else
                printf("1 ");
        }
        printf("\n");
    }
    else
    {
        for(int i=0; i<n ; i++)
        {
            if(i%2==1)
                printf("%d ",a[i]);
            else
                printf("1 ");
        }
        printf("\n");
    }
}
int main()
{
    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}
