#include <bits/stdc++.h>
#define int long long
const int maxn = 1e2 + 9 , modn = 1e9 + 7;
using namespace std;
int t , n , a[maxn];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> t;
	while(t --)
    {
        cin >> n;
        int x = 0 , y = 0 , sum = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            sum += a[i];
            if(i % 2)
                y += a[i];
            else x += a[i];
        }
        if(x <= sum/2){
            for(int i = 0; i < n; i++){
                if(i%2)
                    cout << a[i] << " " ;
                else cout << 1 << " ";
            }
            cout << endl;
        }
        else{
            for(int i = 0; i < n; i++){
                if(i%2)
                    cout << 1 << " ";
                else cout << a[i] << " ";
            }
            cout << endl;
        }
    }
	return 0;
}
