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

#define int long long
#define mod 1000000007
#define pb push_back
#define S second
#define F first
#define inf 1e18
#define all(v) v.begin(), v.end()

#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n" \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  w(tt) {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int &i: v)
      cin >> i;
    for(int i = 0; i < n; ++i) {
      int temp = log2(v[i]); 
      if((1LL << temp) == v[i])
        cout << v[i] << " ";
      else {
        int temp2 = temp + 1;
        if(abs(v[i] - (1LL << temp)) < abs(v[i] - (1LL << temp2)) || (1LL << temp2) > 1e9) {
          cout << (1LL << temp) << " "; 
        }else cout << (1LL << temp2) << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
