#include "bits/stdc++.h"
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        int cur = 1;
        while (cur * 2 <= a[i])
            cur *= 2;
        int c2 = cur * 2;
        int c1 = cur;
        int max = 1e9;
        if (c2 <= max and abs(c2 - a[i]) < abs(c1 - a[i]))
            cur = c2;
        cout << cur << " \n"[i == n - 1];
    }
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int tc;
    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}