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

#define int             long long
#define ld              long double
#define pb              push_back
#define P               pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define db(...)         __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 100005;
const int mod = 1e9 + 7;
int mx = -1e18 , mn = 1e18;

void inp_out()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main(){

    FIO;
    inp_out();
    
    int t; cin>>t; while(t--)
    {
        int i,j,k,n,m,ans = 0,cnt = 0,sum = 0;
        cin>>n;
        int a[n];

        for(i=0;i<n;i++){
            cin>>a[i];
            sum += a[i];
        }


        for(i=0;i<n;i++){
        	if(i&1){
        		ans += abs(a[i]-1);
        	}else{
        		cnt += abs(a[i] - 1);
        	}
        }

        if(ans > cnt){
        	for(i=0;i<n;i++){
        		if(i&1){
        			cout<<a[i]<<" ";
        		}else{
        			cout<<1<<" " ;
        		}
        	}
        }else{
        	for(i=0;i<n;i++){
        		if(i&1){
        			cout<<1<<" " ;
        		}else{
        			cout<<a[i]<<" ";
        		}
        	}
        }


        cout<<"\n";
    }

    return 0;
}