#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        long long sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            sum += a[i];
        }   
        vector<int> b = a;
        long long diff1 = 0;
        for (int i = 0; i < (n); i+=2) {
            b[i] = 1;
            diff1 += a[i] ;          
            diff1 -= b[i];
        }
        if ((2 * diff1) <= sum) {
            for (int i = 0; i < n; i++) {
                cout << b[i] << " ";
            }
        }
        else {
            for (int i = 1; i < n; i += 2) {
                a[i] = 1;
            }
            for (int i = 0; i < n; i++) {
                cout << a[i] << " ";
            }
        }
        
        cout << "\n";
    }
}

