#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  unsigned long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    vector<long long> ans;
    for (long long i = 0; i < n; i++) {
      if (v[i] == 0)
        ans.push_back(0);
      else {
        long long count = 0;
        while (i < n and v[i]) ans.push_back(1), i++, count++;
        i--;
        if (count & 1) ans.pop_back();
      }
    }
    cout << ans.size() << "\n";
    for (auto j : ans) cout << j << " ";
    cout << "\n";
  }
}
