#include<bits/stdc++.h>
using namespace std;
#define int long long
const long long N = 1e9 + 7; 

void solve(){
	int n;
	cin >> n;
	vector<int>a(n);

	int sum = 0;
	for(auto &e : a){
		cin >> e;
		sum += e;
	}

    int odd = 0, even = 0;
	for(int i = 0; i < n; i++){
		if(i % 2)
			odd += abs(a[i] - 1);
		else
			even += abs(a[i] - 1);
	}

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

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

	cout << "\n";

}

int32_t main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);

	int t = 1;
	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}
