#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long int c = 0;
    for (long long int i = 0; i < n - 1; i++) {
      if (a[i] && a[i + 1]) {
        c += 2;
        i++;
      } else if (a[i] == 0)
        c++;
    }
    if (a[n - 1] == 0) c++;
    cout << c << '\n';
    for (long long int i = 0; i < n - 1; i++) {
      if (a[i] && a[i + 1])
        cout << a[i] << " " << a[++i] << " ";
      else if (a[i] == 0)
        cout << a[i] << " ";
    }
    if (a[n - 1] == 0) cout << a[n - 1] << " ";
    cout << endl;
  }
}
