/*
	Create by : Nguyen Tan Khoa
	Date: December 17 2020
	hehe Khoa dinh
*/
#include <bits/stdc++.h>
using namespace std;
long long k[100];
int n;
long long chay(long long o){
	int u =0;
	while (o>=2){
		o=o/2;
		u+=1;
	}
	return u;
}
long long nhan(int x){
	long long u=1;
	for (int i=1;i<x+1;i++){
		u=u*2;
		if (u*2>1000000000){
			return u;
			break;
		}
	}
	return u;
}
void input(){
	cin >> n ;
	for (int i=0;i<n;i++){
		cin >> k[i];
		
	}
}
void solve(){
	long long a[100];
	for (int i=0;i<n;i++){
		if (abs(nhan((chay(k[i])+1))-k[i]) > abs(nhan(chay(k[i]))-k[i])) a[i]=nhan(chay(k[i]));
		else a[i]=nhan((chay(k[i])+1));
	}
	for (int i=0;i<n;i++) cout << a[i] << ' ';
	cout << endl;
}
int main(){
    //freopen("input.inp","r",stdin);
    //freopen("output.out","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	int t;
	cin >> t;
	while (t--){
		input();
		solve();
	}
    return 0;
}