#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000 + 3;

int t, n;
int a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin >> t;
	while (t--)
	{
		cin >> n;
		for (int i = 0; i < n; i++)
			cin >> a[i];
			
		ll sum1 = 0;
		bool isone = false;
		for (int i = 0; i < n; i++)
		{
			if (isone)
				sum1 += a[i];
			isone = !isone;
		}
		
		ll sum2 = 0;
		isone = true;
		for (int i = 0; i < n; i++)
		{
			if (isone)
				sum2 += a[i];
			isone = !isone;
		}
		
		if (sum1 > sum2)
			isone = true;
		else
			isone = false;
		
		for (int i = 0; i < n; i++)
		{
			if (isone)
				cout << 1 << ' ';
			else
				cout << a[i] << ' ';
			isone = !isone;
				
		}
		cout << '\n';
		
	}
}
