#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
ll a[55];
int main(){
	int T , n;
	cin >> T;
	while(T--){
		cin >> n;
		ll odd = 0,even = 0;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			if(i % 2) even += a[i];
			else odd += a[i];
		}
		if(even > odd){
			for(int i = 1; i <= n; i ++){
				if(i % 2 == 0) cout << 1;
				else cout << a[i];
				cout << " ";
			}
		}else{
			for(int i = 1; i <= n; i++){
				if(i % 2 == 0) cout << a[i];
				else cout << 1;
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

