#include <bits/stdc++.h>

using namespace std;

inline void solve() {
    int n;
    cin >> n;

    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> d;

    for(int i = 1; i < 1e9 + 100; i *= 2) {
        d.push_back(i);
    }

    for(int i = 0; i < n; i++) {
        int x = INT_MAX;

        for(int it : d) {
            if(abs(a[i] - it) <= abs(a[i] - x)) {
                x = it;
            }
        }

        cout << x << " ";
    }
    cout << "\n";
}

signed main() {
    time_t _start = clock();

    int t = 1;
    cin >> t;
    while (t--) solve();

    cerr << fixed << "Time: " << (clock() - _start) / (long double) CLOCKS_PER_SEC << "\n";
}