#include <bits/stdc++.h>
using namespace std;
long long power(long long base, long long pow, long long mo) {
  long long res = 1;
  while (pow) {
    if (pow & 1) res = (res * base) % mo;
    base = (base * base) % mo;
    pow /= 2;
  }
  return res;
}
long long Mul(long long a, long long b, long long mo) {
  long long res = 0;
  a %= mo;
  while (b) {
    if (b & 1) res = (res + a) % mo;
    a = (2 * a) % mo;
    b >>= 1;
  }
  return res;
}
bool comp_functor(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second == b.second) {
    return a.first < b.first;
  }
  return a.second > b.second;
}
void Prime(long long n) {
  while (n % 2 == 0) {
    cout << 2 << " ";
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      cout << i << " ";
      n = n / i;
    }
  }
  if (n > 2) cout << n << " ";
}
void Divisors(int n) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        printf("%d ", i);
      else
        printf("%d %d ", i, n / i);
    }
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
void NcR(long long n, long long r) {
  long long p = 1, k = 1;
  if (n - r < r) r = n - r;
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      long long m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else
    p = 1;
  cout << p << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, i, j, k, mini, l1, l2, l3, r1, r2, c, d, maxi, x, y, l, m, r,
      ans, last, flag, lastind, q;
  t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n + 1];
    for (int i = 0; i < n; i++) cin >> a[i];
    ;
    c = 0;
    vector<int> v;
    for (i = 0; i < n; i++) {
      if (a[i] == 1) {
        c++;
      }
      v.push_back(a[i]);
    }
    vector<int> v2;
    j = -1;
    if (c == 0 || c == 1) {
      cout << n - c << "\n";
      for (i = 0; i < n; i++) {
        if (a[i] == 0) {
          cout << 0 << " ";
        }
      }
      cout << "\n";
      continue;
    }
    if (c % 2 == 1) {
      for (i = v.size() - 1; i >= 0; i--) {
        if (v[i] == 1) {
          j = i;
          break;
        }
      }
    }
    for (i = 0; i < v.size(); i++) {
      if (i != j) {
        v2.push_back(v[i]);
      }
    }
    vector<int> final;
    j = -1;
    k = -1;
    for (i = 0; i < v2.size(); i++) {
      if (v2[i] == 1) {
        j = i;
        break;
      }
    }
    for (i = v2.size() - 1; i >= 0; i--) {
      if (v2[i] == 1) {
        k = i;
        break;
      }
    }
    for (i = 0; i < j; i++) {
      final.push_back(0);
    }
    c = 0;
    for (i = j; i <= k; i++) {
      if (v2[i] == 1) {
        if (c % 2 == 1) {
          final.pop_back();
        }
        c = 0;
        final.push_back(1);
      } else {
        c++;
        final.push_back(0);
      }
    }
    for (i = k + 1; i < v2.size(); i++) {
      final.push_back(0);
    }
    cout << final.size() << "\n";
    for (i = 0; i < final.size(); i++) {
      cout << final[i] << " ";
    }
    cout << "\n";
  }
}
