#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ll long long
#define ull unsigned long long
#define MOD 998244353LL
#define INFD INT_MAX
#define INFL 1000000000000000000LL
#define eps 1e-9
#define PI 3.14159265358979
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pow __pow
#define gcd __gcd
#define count __count
#define sd(x) scanf("%d", &(x))
#define slld(x) scanf("%lld", &(x))
#define pd(x) printf("%d\n", (x))
#define plld(x) printf("%lld\n", (x))
#define loop(it, begin, end) for(ll it = begin; it <= end; it++)
#define gc getchar
#define pll pair<ll, ll> 
#define contains(S, x) (S.find(x) != S.end())

const ll N = 50;

ll a[N];

int main() {
	// freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
	ll t; cin >> t;
	while(t--) {
		ll n; cin >> n;
		ll s0 = 0, s1 = 0;
		loop(i, 0, n - 1) {
			cin >> a[i];
			if((i % 2) == 0) {
				s0 += a[i];
			} else{
				s1 += a[i];
			}
		}
		if(s0 >= s1) {
			loop(i, 0, n - 1) {
				if((i % 2) == 1) {
					cout << 1 << " ";
				} else {
					cout << a[i] << " ";
				}
			}
		} else {
			loop(i, 0, n - 1) {
				if((i % 2) == 0) {
					cout << 1 << " ";
				} else {
					cout << a[i] << " ";
				}
			}
		}
		cout << endl;
	}
}