#include<bits/stdc++.h>
#include <string>
#include <unordered_map>
#include <queue>
using namespace std;
#define ll long long int
#define ull unsigned long long int
ll prime = 998244353;
 
 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

 
void solve(){
    unordered_map<string,int> look_up;
    
    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)odd+=a[i];
        else even += a[i];
    }

    int i;
    if(odd>even)i=0;
    else i=1;
    for(int j=0;j<n;j++){
        if(i){
            if((j+1) %2 ==1)cout <<"1"<<" ";
            else cout << a[j]<<" ";
        }
        else {
            if((j+1)%2 ==1)cout <<a[j]<<" ";
            else cout <<"1 ";
        }
    }

         
    cout << endl;
    /*
    */    

}
 
int main()
{   
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll t;
    cin >> t;
 
    while(t--)
    solve();
    return 0;
}