#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
vector<long long int> fact(1000005);
long long int modInverse(long long int a, long long int m) {
  long long int mom = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int top = m;
    m = a % m;
    a = top;
    top = y;
    y = x - q * y;
    x = top;
  }
  if (x < 0) x += mom;
  return x % mod;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
vector<long long int> getAllFactors(long long int n) {
  vector<long long int> v;
  for (long long int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  return v;
}
inline bool isVowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  else
    return false;
}
inline bool isPowerOfTwo(long long int x) { return x && (!(x & (x - 1))); }
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
inline void preComputeFactorial() {
  fact[0] = 1;
  for (long long int i = 1; i <= 1000000; i++)
    fact[i] = (fact[i - 1] % mod * i % mod) % mod;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
long long int computeXOR(long long int n) {
  if (n % 4 == 0) return n;
  if (n % 4 == 1) return 1;
  if (n % 4 == 2)
    return n + 1;
  else
    return 0;
}
long long int setBitNumber(long long int n) {
  long long int k = (long long int)(log2(n));
  return (long long int)(pow(2, k));
}
void subTask1() {}
void subTask2() {}
void subTask3() {}
void subTask4() {}
void a2oJ() {}
void hackerRank() {}
void hackerEarth() {}
void spoj() {}
void codeForces() {
  long long int n;
  cin >> n;
  long long int a[n];
  long long int cnt = 0;
  for (long long int i = 0; i <= n - 1; i++) {
    cin >> a[i];
    if (a[i] == 1) cnt++;
  }
  if (n == 2) {
    if (a[0] == a[1]) {
      cout << 2;
      cout << '\n';
      cout << a[0] << " " << a[1];
      cout << '\n';
    } else {
      cout << 1;
      cout << '\n';
      cout << 0;
      cout << '\n';
    }
    return;
  }
  vector<long long int> r;
  long long int temp = cnt;
  long long int done = 0;
  for (long long int i = 0; i <= n - 1; i++) {
    if (a[i] == 1) {
      if (done & 1) {
        r.push_back(1);
      } else if (cnt - 1 > 0) {
        r.push_back(1);
      }
      cnt -= 1;
      done += 1;
      continue;
    }
    long long int z = 0;
    while (i < n and a[i] == 0) {
      z += 1;
      i += 1;
    }
    if (cnt and cnt != temp) {
      z = z - (z & 1);
    }
    for (long long int j = 0; j <= z - 1; j++) {
      r.push_back(0);
    }
    i -= 1;
  }
  cout << (int)r.size() << endl;
  for (auto id : r) cout << id << ' ';
  cout << endl;
}
void codeChef() {}
void kickStart() {}
void sa() {}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int testcase;
  cin >> testcase;
  for (long long int vv = 1; vv <= testcase; vv++) {
    codeForces();
    codeChef();
    kickStart();
    sa();
    spoj();
    hackerEarth();
    hackerRank();
  }
  return 0;
}
