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

void solve()
{
    long long int n,s=0,d=0,e=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {cin>>a[i];
      s+=a[i];
        if(i%2==0) d+=abs(a[i]-1);
        else e+=abs(a[i]-1);
    }
    if(2*d<=s)
    {for(int i=0;i<n;i++)
        {if(i%2==0)cout<<"1 ";
            else cout<<a[i]<<" ";
        }
    }
    else
    {for(int i=0;i<n;i++)
        {if(i%2==0)cout<<a[i]<<" ";
            else cout<<"1 ";
        }
    }
    cout<<endl;
}   
    

int main()
{
    int t;
    cin>>t;
    while(t--) solve();
}
