#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> V;
  int px = 0;
  while (px < n) {
    if (a[px] == 1) {
      if (px < n && a[px + 1] == 1) {
        px += 2;
        continue;
      }
      V.push_back(px);
    }
    px++;
  }
  px = 0;
  cout << (n - V.size()) << "\n";
  for (int i = 0; i < n; i++) {
    while (px < (V.size()) && V[px] < i) px++;
    if (px < (V.size()) && V[px] == i) continue;
    cout << a[i] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t) {
    t--;
    solve();
  }
}
