#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void pn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << "\n";
  pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  ps(args...);
}
template <typename Arg1>
void pvs(Arg1&& arg1, long long n) {
  for (long long i = 0; i < n; i++) ps(arg1[i]);
}
template <typename Arg1>
void pvn(Arg1&& arg1, long long n) {
  for (long long i = 0; i < n; i++) pn(arg1[i]);
}
int sum(int n) {
  int v = 0;
  while (n != 0) {
    v += (n % 10);
    n /= 10;
  }
  return v;
}
const long long mod = 1000000007;
const long long MOD = 998244353;
const long long inf = 1e18;
const long long MAX = 2e5 + 1;
const unsigned int M = 1000000007;
void solve() {
  long long i, n;
  cin >> n;
  long long a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      v.push_back(0);
    } else if (a[i] == 1 && i != n - 1) {
      if (a[i + 1] == 0)
        continue;
      else {
        v.push_back(1);
        v.push_back(1);
        i++;
      }
    }
  }
  pn(v.size());
  for (int i = 0; i < v.size(); i++) ps(v[i]);
  pn(" ");
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
