Alexandra has an even-length array $a$, consisting of $0$s and $1$s. The elements of the array are enumerated from $1$ to $n$. She wants to remove at most $\frac{n}{2}$ elements (where $n$ — length of array) in the way that alternating sum of the array will be equal $0$ (i.e. $a_1 - a_2 + a_3 - a_4 + \dotsc = 0$). In other words, Alexandra wants sum of all elements at the odd positions and sum of all elements at the even positions to become equal. The elements that you remove don't have to be consecutive.

For example, if she has $a = [1, 0, 1, 0, 0, 0]$ and she removes $2$nd and $4$th elements, $a$ will become equal $[1, 1, 0, 0]$ and its alternating sum is $1 - 1 + 0 - 0 = 0$.

Help her!


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^3$). Description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \le n \le 10^3$, $n$ is even)  — length of the array.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 1$)  — elements of the array.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^3$.


-----Output-----

For each test case, firstly, print $k$ ($\frac{n}{2} \leq k \leq n$) — number of elements that will remain after removing in the order they appear in $a$. Then, print this $k$ numbers. Note that you should print the numbers themselves, not their indices.

We can show that an answer always exists. If there are several answers, you can output any of them. 


-----Example-----
Input
4
2
1 0
2
0 0
4
0 1 1 1
4
1 1 0 0

Output
1
0
1
0
2
1 1
4
1 1 0 0



-----Note-----

In the first and second cases, alternating sum of the array, obviously, equals $0$.

In the third case, alternating sum of the array equals $1 - 1 = 0$.

In the fourth case, alternating sum already equals $1 - 1 + 0 - 0 = 0$, so we don't have to remove anything.

Difficulty: EASY
Tags: Mathematics

Constructive algorithms

Starter code:

Solutions:
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = RLL()
	s1 = sum(a)
	if s1 <= n >> 1:
		print(n >> 1)
		print_list([0] * (n >> 1))
	else:
		d = s1 >> 1 << 1
		print(d)
		print_list([1] * d)


for t in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	if sum(m) <= n // 2:
		print(m.count(0))
		print('0 ' * m.count(0))
	elif sum(m) % 2 == 0:
		print(m.count(1))
		print('1 ' * m.count(1))
	else:
		print(m.count(1) - 1)
		print('1 ' * (m.count(1) - 1))


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	o = ar.count(1)
	z = ar.count(0)
	if z >= o:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
	elif n // 2 % 2:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print(1, end=' ')
	else:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = c = 0
	for i in a:
		if i == 1:
			b += 1
		else:
			c += 1
	if c >= b:
		flag = True
	else:
		flag = False
	if flag:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	else:
		temp = n // 2 + n // 2 % 2
		print(temp)
		for i in range(temp):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = l.count(1)
	z = n - c
	x = n // 2
	if c > n // 2:
		r = [1] * (n // 2)
		if n // 2 % 2 == 1:
			r.append(1)
			x += 1
	elif c == n // 2:
		r = [0] * (n // 2)
	else:
		r = [0] * (n // 2)
	print(x)
	print(*r)


def run_test():
	n = int(input())
	a = list(map(int, input().split()))
	n_0 = sum((1 for x in a if x == 0))
	res = []
	if n_0 < n // 2:
		res = [x for x in a if x == 1]
		if len(res) % 2 == 1:
			res.pop()
	else:
		res = [x for x in a if x == 0]
	print(len(res))
	print(' '.join(map(str, res)))

def main():
	t = int(input())
	for _ in range(t):
		run_test()
main()


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(o, z) = (a.count(1), a.count(0))
	if o < z:
		ans = [i for i in a if i == 0]
	elif o % 2 == 0:
		ans = [i for i in a if i == 1]
	elif o % 2 and o != n // 2:
		ans = [i for i in a if i == 1]
		ans.pop()
	else:
		ans = []
		i = 0
		while i < n:
			if i + 1 < n and a[i] == a[i + 1]:
				ans.append(a[i])
				ans.append(a[i])
				i += 2
			elif i + 2 < n:
				if a[i] != a[i + 2]:
					ans.append(a[i + 1])
					ans.append(a[i + 1])
				else:
					ans.append(a[i])
					ans.append(a[i])
				i += 3
			elif i + 2 == n:
				ans.append(0)
				i += 2
			elif i + 1 == n:
				if a[i] == 0:
					ans.append(0)
				i += 1
	print(len(ans))
	ans = ' '.join(list(map(str, ans)))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c1 = l.count(1)
	c2 = l.count(0)
	if c1 <= c2:
		print(c2)
		l = [0] * c2
		print(*l)
	elif c1 % 2:
		print(c1 - 1)
		l = [1] * (c1 - 1)
		print(*l)
	else:
		print(c1)
		l = [1] * c1
		print(*l)


from sys import stdin, stdout
t = int(stdin.readline())
for case in range(t):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	(one, zero) = (0, 0)
	for item in arr:
		if item == 0:
			zero += 1
		else:
			one += 1
	if one > zero:
		one = one - one % 2
		stdout.write('{}\n'.format(one))
		stdout.write(' '.join(['1'] * one))
	else:
		stdout.write('{}\n'.format(zero))
		stdout.write(' '.join(['0'] * zero))
	stdout.write('\n')


a = int(input())
for i in range(a):
	n = int(input())
	b = [int(s) for s in input().split()]
	s = 0
	ss = 0
	if sum(b) % 2 == 0:
		x = b.count(1)
		y = b.count(0)
		if x < y:
			for j in range(x):
				b.remove(1)
		else:
			for j in range(y):
				b.remove(0)
		print(len(b))
		print(*b)
	else:
		b.remove(1)
		x = b.count(1)
		y = b.count(0)
		if x < y:
			for j in range(x):
				b.remove(1)
		else:
			for j in range(y):
				b.remove(0)
		print(len(b))
		print(*b)


t = int(input())
for _ in range(t):
	l = int(input())
	arr = input().split()
	count_0 = 0
	count_1 = 0
	for i in arr:
		if i == '1':
			count_1 += 1
		else:
			count_0 += 1
	if count_0 >= count_1:
		print(count_0)
		for i in range(count_0 - 1):
			print(0, end=' ')
		print(0)
	elif count_1 > count_0:
		print(count_1 // 2 * 2)
		for i in range(count_1 // 2 * 2 - 1):
			print(1, end=' ')
		print(1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(cz, co) = (0, 0)
	for i in arr:
		if i:
			co += 1
		else:
			cz += 1
	if cz >= co:
		print(cz)
		print('0 ' * cz)
	else:
		co = co - 1 if co % 2 else co
		print(co)
		print('1 ' * co)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(arr, n):
	cnt1 = 0
	cnt0 = 0
	for i in range(n):
		if arr[i] == 0:
			cnt0 += 1
		if arr[i] == 1:
			cnt1 += 1
	if cnt1 <= n // 2:
		print(n - cnt1)
		for i in range(n - cnt1):
			print(0, end=' ')
	else:
		if cnt0 < n // 2 and cnt1 % 2 == 1:
			print(n - cnt0 - 1)
			for i in range(cnt1 - 1):
				print(1, end=' ')
		if cnt0 < n // 2 and cnt1 % 2 == 0:
			print(n - cnt0)
			for i in range(cnt1):
				print(1, end=' ')
t = inp()
while t > 0:
	n = inp()
	arr = inlt()
	solve(arr, n)
	print()
	t -= 1


a = int(input())
for i in range(0, a):
	i = int(input())
	j = list(map(int, input().split()))
	l = j.count(1)
	o = j.count(0)
	if l > o:
		if l % 2 == 1:
			l -= 1
		print(l)
		print('1 ' * l)
	else:
		print(o)
		print('0 ' * o)


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(x, y) = (l.count(1), l.count(0))
	d = []
	if x > y:
		for i in range(0, n, 2):
			if l[i] != l[i + 1]:
				d.append(1)
			elif l[i] == l[i + 1] == 1:
				d.append(l[i])
				d.append(l[i + 1])
		if len(d) % 2 == 1:
			print(len(d) - 1)
			print(*d[:len(d) - 1])
		else:
			print(len(d))
			print(*d)
	else:
		for i in range(0, n, 2):
			if l[i] != l[i + 1]:
				d.append(0)
			elif l[i] == l[i + 1] == 0:
				d.append(l[i])
				d.append(l[i + 1])
		print(len(d))
		print(*d)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = input().split()
	counter = Counter(arr)
	if counter['0'] >= n / 2:
		print(counter['0'])
		print(*[0] * counter['0'], sep=' ')
	elif counter['1'] % 2 == 0:
		print(counter['1'])
		print(*[1] * counter['1'], sep=' ')
	else:
		print(counter['1'] - 1)
		print(*[1] * (counter['1'] - 1), sep=' ')


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	num_1 = a.count(1)
	num_0 = a.count(0)
	if num_1 <= n // 2:
		ans = [0] * num_0
		print(len(ans))
		print(*ans)
	elif num_1 > n // 2 and num_1 % 2 == 0:
		ans = [1] * num_1
		print(len(ans))
		print(*ans)
	else:
		ans = [1] * (num_1 - 1)
		print(len(ans))
		print(*ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().strip().split()))
	index = -1
	count = 0
	list2 = []
	for i in range(n):
		val = list1[i]
		if val == 1:
			if index == -1:
				index = i
				if i % 2 == 0:
					curr = 0
					count += 1
				else:
					curr = 1
					count += 1
				continue
			index = i
			if i % 2 == 0:
				if curr == 0:
					list2.append(i - 1)
				else:
					curr = 0
				count += 1
			else:
				if curr == 0:
					curr = 1
				else:
					list2.append(i - 1)
				count += 1
	if count % 2 != 0 and index != -1:
		list2.append(index)
	print(n - len(list2))
	for i in range(n):
		if i not in list2:
			print(list1[i], end=' ')
	print()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	n = stdint()
	arr = list(stdarr())
	c = Counter(arr)
	if c[1] > c[0]:
		if c[1] & 1 == 1:
			i = c[1] - 1
		else:
			i = c[1]
		x = 1
	else:
		i = c[0]
		x = 0
	print(i)
	print(*[x for __ in range(i)])


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	cnt_0 = arr.count(0)
	if cnt_0 >= n / 2:
		print(cnt_0)
		for i in range(cnt_0):
			print(0, end=' ')
	elif cnt_0 < n / 2:
		print(arr.count(1) - arr.count(1) % 2)
		for i in range(arr.count(1) - arr.count(1) % 2):
			print(1, end=' ')
	print('\t')
	t = t - 1


list_ans = []
for _ in range(int(input())):
	n = int(input()) // 2
	s = input()
	if s.count('0') >= s.count('1'):
		list_ans.append(n)
		list_ans.append('0 ' * (n - 1) + '0')
	elif n % 2 == 0:
		list_ans.append(n)
		list_ans.append('1 ' * (n - 1) + '1')
	else:
		list_ans.append(n + 1)
		list_ans.append('1 ' * n + '1')
for item in list_ans:
	print(item)


for i in range(int(input())):
	n = int(input())
	arr = [int(item) for item in input().split()]
	if arr.count(0) >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print('')
	else:
		print(n // 2 + (n // 2 % 2 != 0))
		for i in range(n // 2 + (n // 2 % 2 != 0)):
			print(1, end=' ')
		print('')


isa = int(input())
for iop in range(isa):
	n = int(input())
	p = input().split()
	for iouy in range(n):
		p[iouy] = int(p[iouy])
	one = p.count(1)
	if one <= n // 2:
		print(n // 2)
		for jpk in range(n // 2):
			print(0, end=' ')
		print()
	elif n // 2 % 2 == 0:
		print(n // 2)
		for jk in range(n // 2):
			print(1, end=' ')
		print()
	else:
		print(n // 2 + 1)
		for llk in range(n // 2 + 1):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	li = map(int, input().split())
	one = 0
	zero = 0
	for i in li:
		if i == 1:
			one += 1
		else:
			zero += 1
	if zero >= n // 2:
		print(zero)
		for i in range(zero):
			print(0, end=' ')
		print()
	else:
		if one % 2 != 0:
			one -= 1
		print(one)
		for i in range(one):
			print(1, end=' ')
		print()


from sys import stdin

def get_int():
	return int(stdin.readline())

def get_str():
	return stdin.readline().strip()

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_array2d(row):
	return [list(map(int, stdin.readline().strip().split())) for _ in range(row)]
T = get_int()
for _ in range(T):
	N = get_int()
	A = get_array()
	cnt = 0
	for a in A:
		cnt += int(a)
	d = cnt & 1
	if cnt <= N // 2:
		cnt = N - cnt
		s = 0
	else:
		cnt = cnt - d
		s = 1
	print(cnt)
	while cnt > 0:
		print(s, end=' ')
		cnt -= 1
	print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		arry = list(map(int, input().split()))
		count0 = 0
		count1 = 0
		for i in range(n):
			if arry[i] == 1:
				count1 += 1
			else:
				count0 += 1
		if count0 > count1:
			if count0 % 2:
				count0 -= 1
			yield count0
			yield ' '.join((str(x) for x in count0 * [0]))
		elif count0 < count1:
			if count1 % 2:
				count1 -= 1
			yield count1
			yield ' '.join((str(x) for x in count1 * [1]))
		else:
			yield count0
			yield ' '.join((str(x) for x in count0 * [0]))
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in ' ' * int(input()):
	a = int(input())
	z = list(map(int, input().split()))
	s = z.count(0)
	k = a // 2
	s1 = z.count(1)
	if s >= s1:
		print(k)
		print('0 ' * k)
	else:
		print(k + k % 2)
		print('1 ' * (k + k % 2))


import collections
import math

def solve(lst):
	ones = 0
	for i in lst:
		if i == 1:
			ones += 1
	zeros = len(lst) - ones
	if ones == len(lst):
		return ['1'] * len(lst)
	elif zeros == len(lst):
		return ['0'] * len(lst)
	if zeros == ones:
		return ['0'] * zeros
	if zeros > ones:
		return ['0'] * zeros
	if ones % 2 == 0:
		return ['1'] * ones
	return ['1'] * (ones - 1)
k = int(input())
for i in range(k):
	k = int(input())
	lst = list(map(int, input().split()))
	p = solve(lst)
	print(len(p))
	print(' '.join(p))


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')

def calcSum(a):
	res = 0
	for i in range(len(a)):
		if i % 2 == 0:
			res += a[i]
		else:
			res -= a[i]
	return res
t = 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	n = len(a)
	i = 0
	while i < len(a):
		if calcSum(a) == 0:
			break
		if a[i] == 0:
			i += 1
			continue
		if i == len(a) - 1:
			a.pop(i)
			continue
		if a[i] == 1 and a[i + 1] == 1:
			i += 2
			continue
		a.pop(i)
	print(len(a))
	print(*a)


def ans(arr):
	ans = []
	o = arr.count('1')
	z = arr.count('0')
	s = 0
	for i in range(len(arr)):
		if i % 2 == 0:
			s += int(arr[i])
		else:
			s -= int(arr[i])
	if s == 0:
		return arr
	if o > len(arr) // 2:
		o -= o % 2
		for i in range(o):
			ans.append('1')
		return ans
	else:
		if z == 1:
			return ['0']
		for i in range(z):
			ans.append('0')
	return ans
a = int(input())
for i in range(a):
	b = int(input())
	n = input().split()
	x = ans(n)
	print(len(x))
	print(*x)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	z = 0
	o = 0
	for i in range(n):
		if l[i] == 0:
			z += 1
		else:
			o += 1
	if o <= n // 2:
		ans = [0] * z
	else:
		ans = [1] * o
		if o % 2:
			ans.pop()
	print(len(ans))
	print(*ans)
t = int(input())
for _ in range(t):
	solution()


T = int(input())
for z in range(T):
	n = int(input())
	a = [int(x) for x in input().split()]
	prev = 0
	l = list()
	for e in a:
		if e == 0:
			l.append(0)
			prev = 0
		elif prev == 0:
			prev = 1
		else:
			l.append(1)
			l.append(1)
			prev = 0
	le = len(l)
	print(le)
	for j in range(le - 1):
		print(l[j], end=' ')
	print(l[le - 1])


from sys import stdin, stdout
from collections import Counter, OrderedDict
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(t,) = mp()
for _ in range(t):
	(n,) = mp()
	a = mp()
	C = Counter(a)
	if C[0] >= n // 2:
		cout(str(C[0]) + '\n')
		pl([0] * C[0])
	elif C[1] >= n // 2:
		if C[1] % 2 == 0:
			cout(str(C[1]) + '\n')
			pl([1] * C[1])
		elif C[1] - 1 >= n // 2:
			cout(str(C[1] - 1) + '\n')
			pl([1] * (C[1] - 1))


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	(c1, c0) = (0, 0)
	for i in range(n):
		if a[i] == 1:
			c1 += 1
		else:
			c0 += 1
	l = 0
	chk = False
	if c0 >= c1:
		print(c0)
		for i in range(c0):
			print(0, end=' ')
		print()
		continue
	else:
		if c1 % 2 == 1:
			c1 -= 1
		print(c1)
		for i in range(c1):
			print(1, end=' ')
		print()
		continue


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	one = 0
	zero = 0
	for i in range(len(s)):
		if s[i] == 1:
			one += 1
		else:
			zero += 1
		if i > 0 and s[i] == 1 and (s[i - 1] == 1):
			f = True
			ans = zero
	if n // 2 % 2 == 0:
		print(n // 2)
		if one > zero:
			for _ in range(n // 2):
				print('1', end=' ')
		else:
			for _ in range(n // 2):
				print('0', end=' ')
		print()
	elif one > zero:
		print(n // 2 + 1)
		for _ in range(0, n // 2 + 1):
			print('1', end=' ')
	else:
		print(n // 2)
		for _ in range(0, n // 2):
			print('0', end=' ')
	print()


import sys
from math import *
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(0) >= a.count(1):
		print(a.count(0))
		print(*[0] * a.count(0))
	else:
		k = a.count(1) if not a.count(1) & 1 else a.count(1) - 1
		print(k)
		print(*[1] * k)


R = lambda : map(int, input().split())
(t,) = R()
for _ in range(t):
	n = int(input())
	arr = input()
	ans = []
	if arr.count('0') >= arr.count('1'):
		ans = [0] * (n // 2)
	else:
		m = n // 2 + n // 2 % 2
		ans = [1] * m
	print(len(ans))
	print(*ans)


a = int(input())
for i in range(a):
	b = int(input())
	l = list(map(int, input().split()))
	c = 0
	co = 0
	for j in range(b):
		if l[j] == 1:
			c += 1
	co = b - c
	if co >= b // 2:
		print(co)
		print(*[0] * co)
	else:
		c = c - c % 2
		print(c)
		print(*[1] * c)


t = int(input())
for _ in range(t):
	n = int(input())
	tab = list(map(int, input().split()))
	ones = sum(tab)
	zeros = len(tab) - ones
	if ones <= n / 2:
		print(zeros)
		for i in range(zeros):
			print('0 ', end='')
		print('')
	else:
		print(ones // 2 * 2)
		for i in range(ones // 2 * 2):
			print('1 ', end='')
		print('')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(0, n, 2):
		if a[i] == a[i + 1]:
			ans.extend([a[i], a[i]])
		else:
			ans.append(0)
	print(len(ans))
	print(*ans)


def read(datatype=int):
	return datatype(input())

def readl(datatype=int):
	return list(map(datatype, input().split()))

def printl(data):
	string = ''
	for d in data:
		string += str(d) + ' '
	print(string)

def get_counts(arr):
	odd = 0
	even = 0
	for i in range(len(arr)):
		if i % 2 == 0:
			even += arr[i]
		else:
			odd += arr[i]
	return (odd, even)

def testcase():
	n = read()
	arr = readl()
	if arr == [1, 1] or arr == [0]:
		print(2)
		printl(arr)
		return
	if arr == [0, 1] or arr == [1, 0]:
		print(1)
		print(0)
		return
	ans = []
	index = 0
	while index < n and arr[index] == 0:
		ans.append(0)
		index += 1
	ones = arr.count(1)
	leave_last_one = ones % 2 == 1
	zeroes = 0
	while index < n:
		if arr[index] == 1:
			if ones == 1 and leave_last_one:
				index += 1
				continue
			ones -= 1
			for _ in range(zeroes & ~1):
				ans.append(0)
			ans.append(1)
			zeroes = 0
		else:
			zeroes += 1
		index += 1
	for _ in range(zeroes):
		ans.append(0)
	print(len(ans))
	printl(ans)
	return
t = read()
for _ in range(t):
	testcase()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	suma = sum(a)
	if suma <= n // 2:
		print(n - suma)
		for i in range(n - suma):
			print(0, end=' ')
	else:
		k = n // 2
		if k % 2 == 1:
			k += 1
		print(k)
		for i in range(k):
			print(1, end=' ')
	print()


import collections
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [*map(int, input().split())]
	counter = collections.Counter(arr)
	if counter[0] >= n // 2:
		print(counter[0])
		print(' '.join(['0'] * counter[0]))
	elif n // 2 % 2 == 0:
		print(n // 2)
		print(' '.join(['1'] * (n // 2)))
	else:
		print(n // 2 + 1)
		print(' '.join(['1'] * (n // 2 + 1)))


for p in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = arr.count(1)
	y = arr.count(0)
	if x > y:
		if n // 2 % 2 == 1:
			print(n // 2 + 1)
			print('1 ' * (n // 2 + 1))
		else:
			print(n // 2)
			print('1 ' * (n // 2))
	else:
		print(n // 2)
		print('0 ' * (n // 2))


for I in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ones = 0
	zeros = 0
	for num in a:
		if num == 1:
			ones += 1
		else:
			zeros += 1
	half = n // 2
	if zeros >= half:
		print(half)
		for i in range(half):
			print(0, end=' ')
	elif ones >= half:
		if half % 2 == 1:
			print(half + 1)
			for i in range(half + 1):
				print(1, end=' ')
		else:
			print(half)
			for i in range(half):
				print(1, end=' ')
	print()


import sys
from math import sqrt
from collections import defaultdict
inpt = sys.stdin.readline

def inp():
	return int(inpt())

def inlist():
	return list(map(int, inpt().split()))

def instr():
	s = inpt()
	return list(s[:len(s) - 1])

def inbitstr():
	s = inpt()
	return [int(i) for i in list(s[:len(s) - 1])]

def invr():
	return map(int, inpt().split())

class Graph:

	def __init__(self, n):
		self.n = n
		self.graph = defaultdict(list)
		self.marked = defaultdict(int)

	def addEdge(self, u, v):
		self.graph[u].append(v)
		self.graph[v].append(u)

	def cleanup(self):
		self.marked = defaultdict(int)

	def dfs(self, u):
		self.marked[u] = 1
		(max, maxnode) = (0, u)
		for i in self.graph[u]:
			(cur, node) = (0, 0)
			if self.marked[i] == 0:
				(cur, node) = self.dfs(i)
			if cur > max:
				max = cur
				maxnode = node
		return (1 + max, maxnode)

	def lngdfs(self, u, v):
		self.marked[u] = 1
		max = self.n
		for i in self.graph[u]:
			if i == v:
				return 1
			cur = self.n
			if self.marked[i] == 0:
				cur = self.lngdfs(i, v)
			if cur < max:
				max = cur
		return 1 + max

def main():
	t = inp()
	for l in range(t):
		n = inp()
		a = inlist()
		s = []
		for i in range(0, n, 2):
			if a[i] == a[i + 1]:
				s.append(a[i])
				s.append(a[i + 1])
			else:
				s.append(0)
		print(len(s))
		for i in range(len(s)):
			print(s[i], end=' ')
		print()
main()


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	zero = l.count(0)
	one = l.count(1)
	ans = []
	if zero == one:
		if zero == 1:
			ans.append(0)
		elif zero % 2 == 0:
			ans = [0] * zero
		else:
			f = -1
			(zerocount, onecount) = (0, 0)
			for i in l:
				if i == 0:
					zerocount += 1
				else:
					onecount += 1
				if zerocount == zero - 1:
					f = 0
					break
				elif onecount == one - 1:
					f = 1
					break
			if f == 0:
				ans = [0] * (zero - 1)
				ans.append(1)
				ans.append(1)
			elif f == 1:
				ans = [1] * (one - 1)
				ans.append(0)
				ans.append(0)
	elif zero > one:
		if zero % 2 == 0:
			ans = [0] * zero
		else:
			ans = [0] * (zero - 1)
	elif one % 2 == 0:
		ans = [1] * one
	else:
		ans = [1] * (one - 1)
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c0 = a.count(0)
	c1 = a.count(1)
	if c1 > c0:
		if c1 % 2 == 1:
			c1 -= 1
		print(c1)
		print('1 ' * c1)
	else:
		print(c0)
		print('0 ' * c0)


from __future__ import division, print_function
import sys
sys.setrecursionlimit(10 ** 4)
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f

def primeFactors(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			a.append(i)
			n = n // i
	if n > 2:
		a.append(n)
	return a

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		a = ain()
		x = 0
		for i in a:
			if i == 0:
				x += 1
		y = n - x
		b = []
		if x < y:
			if y % 2 == 1:
				y -= 1
			print(y)
			print(*[1] * y)
		else:
			print(x)
			print(*[0] * x)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'R'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'R'[0]:
		A.append(sign * numb)
	return A
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	for (i, val) in enumerate(a):
		if i % 2 == 0:
			s += val
		else:
			s -= val
	for i in range(n - 1, 0, -2):
		if a[i] == a[i - 1]:
			pass
		elif a[i] == 1:
			a.pop(i)
		else:
			a.pop(i - 1)
	print(len(a))
	print(' '.join((str(num) for num in a)))


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	x = list(map(int, stdin.readline().split()))
	count1 = x.count(1)
	count0 = x.count(0)
	if count1 > count0:
		count1 = count1 - count1 % 2
		print(count1)
		for i in range(count1):
			print(1, end=' ')
	else:
		print(count0)
		for i in range(count0):
			print(0, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 2
	for i in a:
		b[i] += 1
	if b[1] * 2 <= n:
		k = b[0]
		ans = [0] * k
	else:
		k = b[1]
		if k % 2:
			k -= 1
		ans = [1] * k
	print(k)
	print(*ans)


from sys import stdin, stdout
inp = stdin.readline
out = stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		one = a.count(1)
		zero = n - one
		if zero == one:
			print(n // 2)
			f = [0] * (n // 2)
			print(*f)
		elif zero > one:
			print(n // 2)
			f = [0] * (n // 2)
			print(*f)
		elif n // 2 % 2 == 0:
			print(n // 2)
			f = [1] * (n // 2)
			print(*f)
		else:
			print(n // 2 + 1)
			f = [1] * (n // 2 + 1)
			print(*f)
main()


from sys import stdin
n1 = int(stdin.readline().strip())
for j in range(n1):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	x = s.count(1)
	if x % 2 != 0:
		s.remove(1)
	ans = []
	ind = 0
	par = 0
	impar = 0
	last = -1
	for i in range(len(s)):
		if s[i] == 1:
			if last == -1:
				last = i
			elif abs(i - last) % 2 == 0:
				ans.pop()
				last = -1
			else:
				last = -1
		ans.append(s[i])
	print(len(ans))
	print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ZERO = A.count(0)
	if ZERO >= n // 2:
		print(ZERO)
		print(*[0] * ZERO)
	else:
		ONE = n - ZERO
		print(ONE // 2 * 2)
		print(*[1] * (ONE // 2 * 2))


t = int(input())
for _ in range(t):
	n = int(input())
	ls = [int(a) for a in input().split()]
	ctr0 = ls.count(0)
	an = ''
	t1 = int(n / 2)
	if ctr0 >= t1:
		for i in range(int(n / 2)):
			an += '0 '
	else:
		if t1 % 2:
			t1 += 1
		for i in range(t1):
			an += '1 '
	print(t1)
	print(an)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 2:
		if 0 in l:
			print(1)
			print(0)
		else:
			print(2)
			print(' '.join(list(map(str, l))))
	elif l.count(1) > l.count(0):
		print(n - l.count(0) - l.count(0) % 2)
		print(' '.join(list(map(str, (l.count(1) - l.count(0) % 2) * [1]))))
	else:
		print(n - l.count(1))
		print(' '.join(list(map(str, l.count(0) * [0]))))


import math as mt

def tran(arr):
	z = arr.count(0)
	o = arr.count(1)
	if z >= o:
		return [0] * z
	elif o % 2 == 0:
		return [1] * o
	else:
		return [1] * (o - 1)
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	r = tran(arr)
	ans.append(r)
for i in ans:
	print(len(i))
	print(*i)


for test in range(int(input())):
	pocet = int(input())
	vstup = list(map(int, input().split(' ')))
	output = ''
	k = 0
	for i in range((pocet + 2) // 4):
		if (i + 1) * 4 <= pocet:
			lst = vstup[i * 4:i * 4 + 4]
			if max(set(lst), key=lst.count) == 1:
				output = output + '1 1 '
				k += 2
			else:
				output = output + '0 0 '
				k += 2
		elif vstup[i * 4] == 0 or vstup[i * 4 + 1] == 0:
			output = output + '0 '
			k += 1
		else:
			output = output + '1 1 '
			k += 2
	print(k)
	output = output[:-1]
	print(output)


t = int(input())
for c in range(t):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	oc_0 = arr.count(0)
	oc_1 = arr.count(1)
	if oc_0 >= oc_1:
		print(oc_0)
		for i in range(oc_0):
			print('0', end=' ')
		print()
	else:
		print(2 * (oc_1 // 2))
		for i in range(2 * (oc_1 // 2)):
			print('1', end=' ')
		print()


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	cntr = Counter(ar)
	if n / 2 >= cntr[1]:
		print(cntr[0])
		print(*[0] * cntr[0])
	elif n == 3:
		print(2)
		print(*[1, 1])
	elif cntr[1] - cntr[0] != 1:
		print(cntr[1] - cntr[1] % 2)
		print(*[1] * (cntr[1] - cntr[1] % 2))
	elif ar[0] == 0:
		print(cntr[1])
		print(*[0] + [1] * (cntr[1] - 1))
	elif ar[-1] == 0:
		print(cntr[1])
		print(*[1] * (cntr[1] - 1) + [0])
	else:
		print(cntr[1] + 1)
		print(*[1] + [0] * cntr[0] + [1])


def find_num(n, n_list):
	answer_arr = []
	count = 0
	for i in range(n):
		if not n_list[i]:
			count += 1
	count_1 = n - count
	if count >= n // 2:
		answer_arr.append(count)
		for i in range(count):
			answer_arr.append(0)
	else:
		temp = count_1 - count_1 % 2
		answer_arr.append(temp)
		for i in range(temp):
			answer_arr.append(1)
	return answer_arr
t = int(input())
temp_a = [[]]
ans_a = []
for i in range(t):
	n = int(input())
	n_list = list(map(int, input().split()))
	ans_a = find_num(n, n_list)
	temp_a.append(ans_a)
del temp_a[0]
for r in range(len(temp_a)):
	print(temp_a[r][0])
	for c in range(1, len(temp_a[r])):
		print(temp_a[r][c], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	for j in a:
		if j == 1:
			c += 1
	if c <= n / 2:
		print(n - c)
		print('0 ' * (n - c - 1) + '0')
	elif c % 2 == 0:
		print(c)
		print('1 ' * (c - 1) + '1')
	else:
		print(c - 1)
		print('1 ' * (c - 2) + '1')


import sys as _sys

def main():
	t = int(input())
	for i in range(t):
		(n,) = _read_ints()
		a = tuple(_read_ints())
		fixed_a = fix_array(a)
		print(len(fixed_a))
		print(*fixed_a)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split(' '))

def fix_array(array):
	array = tuple(array)
	assert len(array) % 2 == 0
	fixed_array = []
	i = 0
	while i < len(array):
		if not i + 1 < len(array):
			if array[i] == 0:
				fixed_array.append(0)
			i += 1
			continue
		(a, b) = (array[i], array[i + 1])
		if a == b:
			fixed_array.append(a)
			fixed_array.append(b)
			i += 2
			continue
		if i + 2 < len(array):
			c = array[i + 2]
			if c == a:
				fixed_array.append(a)
				fixed_array.append(c)
			else:
				assert c == b
				fixed_array.append(b)
				fixed_array.append(c)
			i += 3
		else:
			assert a == 0 or b == 0
			fixed_array.append(0)
			i += 2
	return fixed_array
main()


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	c0 = 0
	c1 = 1
	for x in a:
		c0 += int(x == 0)
		c1 += int(x == 1)
	if c0 >= round(n / 2):
		print(round(n / 2))
		print(*[0] * round(n / 2))
	elif round(n / 2) % 2 == 0:
		print(round(n / 2))
		print(*[1] * round(n / 2))
	else:
		print(round(n / 2) + 1)
		print(*[1] * (round(n / 2) + 1))


T = int(input())
for _ in range(T):
	n = int(input())
	lis = list(map(int, input().split()))
	res = []
	for i in range(0, n, 2):
		if lis[i] > lis[i + 1]:
			res.append(lis[i + 1])
		elif lis[i] < lis[i + 1]:
			res.append(lis[i])
		else:
			res.append(lis[i])
			res.append(lis[i + 1])
	print(len(res))
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	zero = 0
	one = 0
	for i in range(n):
		if s[i] == 1:
			one += 1
		else:
			zero += 1
	if zero >= one:
		print(zero)
		for i in range(zero):
			print(0, end=' ')
		print('\t')
	else:
		if one % 2 != 0:
			one -= 1
		print(one)
		for i in range(one):
			print(1, end=' ')
		print('\t')


import sys, collections
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	a = inpl()
	c = [0, 0]
	for x in a:
		c[x] += 1
	if c[0] >= c[1]:
		print(c[0])
		print(*[0] * c[0])
	else:
		if c[1] % 2:
			c[1] -= 1
		print(c[1])
		print(*[1] * c[1])


import sys

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())

def flush():
	sys.stdout.flush()
for _ in range(getInt()):
	n = getInt()
	a = getIntList()
	half = n // 2
	evenH = half + half % 2
	if a.count(0) >= half:
		print(half)
		print('0 ' * half)
	else:
		print(evenH)
		print('1 ' * evenH)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ones = arr.count(1)
	zeros = arr.count(0)
	ch = '0'
	if zeros == ones:
		print(n // 2)
		print(' '.join(['0' for x in range(n // 2)]))
		continue
	if ones > zeros:
		ch = '1'
	c = n // 2 if n // 2 % 2 == 0 else n // 2 + 1
	print(c)
	print(' '.join([str(ch) for x in range(c)]))


t = int(input())
for test in range(t):
	N = int(input())
	arr = [int(i) for i in input().split(' ')]
	s = ''
	k = 0
	j = 0
	while j <= N - 1:
		if arr[j] + arr[j + 1] == 1:
			k = k + 1
			s = s + '0 '
		if arr[j] + arr[j + 1] == 0:
			k = k + 2
			s = s + '0 0 '
		if arr[j] + arr[j + 1] == 2:
			k = k + 2
			s = s + '1 1 '
		j = j + 2
	print(k)
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	z = l.count(0)
	o = n - z
	if z >= o:
		print(n // 2)
		print('0 ' * (n // 2))
	elif n % 4:
		print(n // 2 + 1)
		print('1 ' * (n // 2 + 1))
	else:
		print(n // 2)
		print('1 ' * (n // 2))


iter = int(input())
for _ in range(iter):
	n = int(input())
	a = list(map(int, input().split(' ')))
	count = 0
	for i in range(n):
		if a[i] == 0:
			count += 1
	if count >= n // 2:
		print(count)
		print('0 ' * count)
	elif count & 1:
		print(n - count - 1)
		print('1 ' * (n - count - 1))
	else:
		print(n - count)
		print('1 ' * (n - count))


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def ip():
	return int(sys.stdin.readline())

def sip():
	return sys.stdin.readline()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
t = ip()
while t:
	t -= 1
	n = ip()
	arr = lip()
	if n == 2:
		if arr[0] == arr[1]:
			print(2)
			print(*arr)
		else:
			print(1)
			print(0)
	else:
		i = 1
		lst = []
		while i < n:
			if arr[i] == arr[i - 1]:
				lst.append(arr[i])
				lst.append(arr[i - 1])
				i += 2
			elif i < n - 1:
				if arr[i] == arr[i + 1]:
					lst.append(arr[i])
					lst.append(arr[i + 1])
				else:
					lst.append(arr[i - 1])
					lst.append(arr[i + 1])
				i += 3
			else:
				i += 1
		print(len(lst))
		print(*lst)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	evenSum = 0
	oddSum = 0
	OI = []
	ZI = []
	for i in range(1, n + 1):
		if arr[i - 1] == 0:
			ZI.append(i - 1)
		if arr[i - 1] == 1:
			OI.append(i - 1)
		if i % 2 == 1:
			oddSum += arr[i - 1]
		else:
			evenSum += arr[i - 1]
	if len(ZI) >= n / 2:
		print(len(ZI))
		print('0 ' * len(ZI))
	else:
		g = len(OI) - len(OI) % 2
		print(g)
		print('1 ' * g)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(cnt1, cnt0) = (a.count(1), a.count(0))
	if cnt1 <= n / 2:
		print(cnt0)
		for _ in range(cnt0):
			print(0, end=' ')
	else:
		if cnt1 % 2 == 1:
			cnt1 -= 1
			print(cnt1)
		else:
			print(cnt1)
		for _ in range(cnt1):
			print(1, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c1 = l.count(1)
	c0 = l.count(0)
	if c1 == 0:
		print(n)
		print(*l)
	elif c0 == 0:
		print(n)
		print(*l)
	elif c1 > c0:
		if c1 % 2 == 0:
			print(n - c0)
			k = []
			for i in range(n - c0):
				k.append(1)
			print(*k)
		elif n // 2 % 2 != 0:
			print(n // 2 + 1)
			k = []
			for i in range(n // 2 + 1):
				k.append(1)
			print(*k)
		else:
			print(n // 2)
			k = []
			for i in range(n // 2):
				k.append(1)
			print(*k)
	else:
		print(n // 2)
		k = []
		for i in range(n // 2):
			k.append(0)
		print(*k)


N = int(input())
for i in range(N):
	n = int(input())
	a = list(map(int, input().split()))
	one_cnt = sum(a)
	zero_cnt = n - one_cnt
	if zero_cnt >= one_cnt:
		print(zero_cnt)
		for _ in range(zero_cnt):
			print(0, end=' ')
	else:
		if one_cnt % 2 == 1:
			one_cnt -= 1
		print(one_cnt)
		for _ in range(one_cnt):
			print(1, end=' ')
	print()


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	(c0, c1) = (0, 0)
	for elem in arr:
		if elem == 0:
			c0 += 1
		else:
			c1 += 1
	if c0 >= n // 2:
		ans = [0] * (n // 2)
		print(len(ans))
		print(*ans)
	elif c1 % 2 == 0:
		ans = [1] * c1
		print(len(ans))
		print(*ans)
	else:
		ans = [1] * (c1 - 1)
		print(len(ans))
		print(*ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for case in range(t):
	n = int(input())
	array = input().split(' ')
	res = []
	if n % 4 == 0:
		for i in range(0, n, 4):
			a = array[i]
			if a == array[i + 1] or a == array[i + 2]:
				res += [a, a]
			else:
				res += [array[i + 1], array[i + 1]]
		print(n // 2)
	elif n > 2:
		for i in range(0, n - 6, 4):
			a = array[i]
			if a == array[i + 1] or a == array[i + 2]:
				res += [a, a]
			else:
				res += [array[i + 1], array[i + 1]]
		for i in range(n - 6, n, 3):
			a = array[i]
			if a == array[i + 1] or a == array[i + 2]:
				res += [a, a]
			else:
				res += [array[i + 1], array[i + 1]]
		print(n // 2 + 1)
	elif array[1] == array[0]:
		print(2)
		res += [array[1], array[1]]
	else:
		print(1)
		res = ['0']
	print(' '.join(res))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(0) >= n // 2:
		print(n // 2)
		print(' '.join('0' * (n // 2)))
	else:
		m = n // 2
		if m % 2 == 1:
			m += 1
		print(m)
		print(' '.join('1' * m))
t = int(input())
for _ in range(t):
	solve()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	z = a.count(0)
	one = a.count(1)
	if one <= n // 2:
		print(n - one)
		print(*[0] * (n - one), sep=' ')
	else:
		c = n // 2
		if n // 2 % 2 == 1:
			c += 1
		print(c)
		for i in range(n):
			if a[i] == 1:
				if c > 0:
					c -= 1
					print(a[i], end=' ')
		print()


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = inar()
		one = 0
		zero = 0
		for i in range(n):
			if arr[i] == 0:
				zero += 1
			else:
				one += 1
		if zero >= n // 2:
			print(n // 2)
			ar = [0] * (n // 2)
			print(*ar)
		elif one % 2 == 0:
			print(one)
			ar = [1] * one
			print(*ar)
		else:
			print(one - 1)
			ar = [1] * (one - 1)
			print(*ar)
main()


for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	one = a.count(1)
	two = a.count(0)
	if one <= N // 2:
		a = list(filter(lambda a: a != 1, a))
		print(len(a))
		print(*a)
	elif two <= N // 2:
		a = list(filter(lambda a: a != 0, a))
		if a.count(1) % 2 == 1:
			a.remove(1)
		print(len(a))
		print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(x, y) = (0, 0)
	for i in a:
		if i == 0:
			y += 1
		else:
			x += 1
	if x <= n / 2:
		print(y)
		for i in range(y):
			print(0, end=' ')
		print()
	else:
		if x % 2 == 1:
			x -= 1
		print(x)
		for i in range(x):
			print(1, end=' ')
		print()


t = int(input())
for _ipj_ in range(t):
	n = int(input())
	l = list(input().split())
	z = l.count('0')
	o = n - z
	if o % 2 == 0:
		if o < z:
			print(z)
			for i in range(z):
				print('0', end=' ')
		else:
			print(o)
			for i in range(o):
				print('1', end=' ')
	elif o <= z:
		print(z)
		for i in range(z):
			print('0', end=' ')
	else:
		print(o - 1)
		for i in range(o - 1):
			print('1', end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	half = int(n / 2)
	if a.count(0) >= half:
		print(a.count(0))
		for i in a:
			if i == 0:
				print(str(i) + ' ', end='')
	else:
		ones = a.count(1)
		how_many_ones = 0
		if ones % 2 == 0:
			print(ones)
			for i in a:
				if i == 1:
					print(str(i) + ' ', end='')
		else:
			print(ones - 1)
			for i in a:
				if i == 1 and how_many_ones < ones - 1:
					print(str(i) + ' ', end='')
					how_many_ones += 1
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c0 = 0
	c1 = 0
	for i in range(n):
		if arr[i] == 1:
			c1 += 1
		else:
			c0 += 1
	if c0 >= c1:
		print(c0)
		print(*[0] * c0)
	else:
		if c1 % 2 != 0:
			c1 -= 1
		print(c1)
		print(*[1] * c1)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		(a1, ls) = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	n = I()
	a = LI()
	k = n // 2
	x = k
	if sum(a) > k:
		if k % 2 == 1:
			ans = [1] * (k + 1)
			x = k + 1
		else:
			ans = [1] * k
			x = k
	else:
		ans = [0] * k
	print(x)
	print(*ans)


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	n1 = 0
	for i in range(n):
		if a[i] == 1:
			n1 += 1
	if n1 <= n // 2:
		print(n - n1)
		for i in range(n - n1):
			print(0, end=' ')
		print('')
		continue
	n1 = n1 - n1 % 2
	print(n1)
	for i in range(n1):
		print(1, end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	x = 0
	y = 0
	for i in a:
		if i == 0:
			x += 1
		else:
			y += 1
	if x >= n // 2:
		print(x)
		for i in range(x):
			print(0, end=' ')
	else:
		if y % 2:
			y -= 1
		print(y)
		for i in range(y):
			print(1, end=' ')
	print()


(T,) = map(int, input().split())
for i in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	c = sum(X)
	if 2 * c <= N:
		print(N - c)
		print(*[0] * (N - c))
	elif c % 2:
		print(c - 1)
		print(*[1] * (c - 1))
	else:
		print(c)
		print(*[1] * c)


for _ in range(int(input())):
	n = int(input())
	lst = input().split()
	one = lst.count('1')
	zero = lst.count('0')
	if one > zero:
		lst = list(filter(lambda x: x == '1', lst))
		if len(lst) % 2 == 0:
			print(len(lst))
			print(' '.join(lst))
		else:
			lst.pop()
			print(len(lst))
			print(' '.join(lst))
	else:
		lst = list(filter(lambda x: x == '0', lst))
		print(len(lst))
		print(' '.join(lst))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = [int(x) for x in input().split()]
		count = 0
		for i in range(n):
			if arr[i] == 0:
				count += 1
		if count >= n // 2:
			print(count)
			answer = ' '.join(['0'] * count)
		elif (n - count) % 2 == 0:
			print(n - count)
			answer = ' '.join(['1'] * (n - count))
		else:
			print(n - count - 1)
			answer = ' '.join(['1'] * (n - count - 1))
		print(answer)
main()


for t in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	i = 0
	out = []
	while i < len(num):
		if i == len(num) - 1:
			if num[i] == 0:
				out.append(0)
			break
		if num[i] == num[i + 1]:
			out.append(num[i])
			out.append(num[i + 1])
			i += 2
		elif i + 2 < len(num):
			if num[i + 2] == num[i]:
				out.append(num[i])
			else:
				out.append(num[i + 1])
			out.append(num[i + 2])
			i += 3
		else:
			if num[i] == 1:
				out.append(num[i + 1])
			else:
				out.append(num[i])
			i += 2
	print(len(out))
	print(*out)


for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	a = [0] * n
	ans = []
	k = 0
	sm = sum(u)
	cnt = 0
	for i in range(n):
		if u[i] == 0:
			k += 1
			ans.append(0)
		elif k % 2 == 1 and cnt > 0:
			if cnt == sm - 1 and sm % 2 == 1:
				ans.pop()
			else:
				ans[-1] = 1
				cnt += 1
				k = 0
		else:
			if cnt == sm - 1 and sm % 2 == 1:
				continue
			ans.append(1)
			cnt += 1
			k = 0
	print(len(ans))
	print(' '.join(map(str, ans)))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		c = Counter(a)
		n0 = c[0]
		n1 = c[1]
		if n0 >= n // 2:
			print(n // 2)
			print('0 ' * (n // 2))
		elif n1 % 2 == 0:
			print(n1)
			print('1 ' * n1)
		else:
			n1 -= 1
			if n1 >= n // 2:
				print(n1)
				print('1 ' * n1)
			else:
				n0 = 1
				ans = []
				n0g = 0
				n1g = 0
				for i in a:
					if i == 0 and n0g < 1:
						n0g += 1
						ans.append(0)
					if i == 1 and n1g < n1:
						n1g += 1
						ans.append(1)
				print(len(ans))
				print(*ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	A = list(map(int, input().split(' ')))
	if A.count(1) <= n // 2:
		print(A.count(0))
		for i in range(n):
			if A[i] == 0:
				print(A[i], end=' ')
		print()
	elif A.count(1) % 2 == 0:
		print(A.count(1))
		for i in range(n):
			if A[i] == 1:
				print(A[i], end=' ')
		print()
	else:
		c = 0
		print(A.count(1) - 1)
		for i in range(n):
			if A[i] == 1 and c > 0:
				print(A[i], end=' ')
			if A[i] == 1:
				c += 1
		print()


T = int(input())
for __ in range(T):
	n = int(input())
	nums = list(map(int, input().split()))
	result = []
	for i in range(n // 3):
		slc = nums[i * 3:(i + 1) * 3]
		cnt = {0: 0, 1: 0}
		for x in slc:
			cnt[x] += 1
		if cnt[0] > cnt[1]:
			result.extend([0, 0])
		else:
			result.extend([1, 1])
	j = n % 3
	if j == 2:
		(p, q) = (nums[-2], nums[-1])
		if p == q:
			result.extend([p, q])
		else:
			result.extend([0])
	print(len(result))
	print(' '.join(map(str, result)))


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	ones = sum(a)
	z = n - ones
	if ones == n or ones == 0:
		print(n)
		for i in range(n):
			print(a[i], end=' ')
	elif ones <= n // 2:
		print(z)
		for i in range(z):
			print(0, end=' ')
	else:
		if ones % 2 != 0:
			ones -= 1
		print(ones)
		for i in range(ones):
			print(1, end=' ')
	print()


from collections import Counter
x = int(input())
for _ in range(x):
	n = int(input())
	nums = [int(num) for num in input().split(' ')]
	map_ = Counter(nums)
	if map_[1] <= n // 2:
		print(map_[0])
		print('0 ' * map_[0])
	else:
		print(map_[1] - map_[1] % 2)
		print('1 ' * (map_[1] - map_[1] % 2))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	i = 0
	while i < n:
		if a[i] == 0:
			ans.append(0)
			i += 1
		elif i + 1 < n and a[i] == 1 and (a[i + 1] == 1):
			ans.append(1)
			ans.append(1)
			i += 2
		else:
			i += 1
	print(len(ans))
	print(*ans)


for t in range(int(input())):
	num = int(input())
	arr = list(map(int, input().split()))
	ones = arr.count(1)
	zeros = arr.count(0)
	if zeros >= num // 2:
		print(zeros)
		for i in range(num):
			if arr[i] == 0:
				print(0, end=' ')
	else:
		if ones % 2 != 0:
			ones -= 1
		print(ones)
		count = 0
		for i in range(num):
			if arr[i] == 1:
				print(1, end=' ')
				count += 1
				if count == ones:
					break
	print('')


for s in [*open(0)][2::2]:
	n = []
	for (l, r) in zip(s[::4], s[2::4]):
		n += [1, 1] if '11' == l + r else [0]
	print(len(n), *n)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	one = a.count(1)
	if one % 2 == 1:
		one -= 1
	zero = a.count(0)
	ans = []
	if one > zero:
		for i in range(one):
			ans.append(1)
	else:
		for i in range(zero):
			ans.append(0)
	print(len(ans))
	print(*ans)


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	from collections import Counter
	input = sys.stdin.buffer.readline
	for _ in range(int(input())):
		N = int(input())
		A = list(map(int, input().split()))
		if N == 2:
			if A[0] == A[1] == 1:
				print(2)
				print(1, 1)
			else:
				print(1)
				print(0)
			continue
		C = Counter(A)
		if N // 2 % 2 == 0:
			if C[0] >= C[1]:
				a = 0
			else:
				a = 1
			print(N // 2)
			print(*[a] * (N // 2))
		else:
			n = N // 2
			if C[0] >= n + 1:
				print(n + 1)
				print(*[0] * (n + 1))
			elif C[1] >= n + 1:
				print(n + 1)
				print(*[1] * (n + 1))
			else:
				print(n)
				print(*[0] * n)
main()


try:
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		c = l.count(1)
		d = l.count(0)
		if c > d:
			if c % 2 == 0:
				print(c)
				print(*[1] * c, sep=' ')
			else:
				print(c - 1)
				print(*[1] * (c - 1), sep=' ')
		else:
			print(d)
			print(*[0] * d, sep=' ')
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	odd = []
	even = []
	ct_1_odd = 0
	ct_1_even = 0
	ans = []
	for i in range(n):
		if (i + 1) % 2 == 0:
			even.append(arr[i])
			if arr[i] == 1:
				ct_1_even += 1
		else:
			odd.append(arr[i])
			if arr[i] == 1:
				ct_1_odd += 1
	if ct_1_odd == ct_1_even:
		print(len(arr))
		print(*arr)
		continue
	else:
		i = 0
		ans = []
		while i < n - 1:
			if arr[i] == 0:
				ans.append(0)
				i += 1
			elif arr[i] == 1 and arr[i + 1] == 1:
				ans.append(1)
				ans.append(1)
				i += 2
			else:
				i += 1
		if arr[-1] == 0:
			ans.append(0)
		print(len(ans))
		print(*ans)


def ans(n, arr):
	c0 = 0
	c1 = 0
	for i in arr:
		if i == 0:
			c0 += 1
		else:
			c1 += 1
	mid = n // 2
	ans = []
	if c0 >= mid:
		ans = ['0'] * mid
	elif c1 > mid and mid % 2 == 0:
		ans = ['1'] * mid
	elif c1 > mid and mid % 2 != 0:
		ans = ['1'] * (mid + 1)
	return [len(ans), ' '.join(ans)]
T = int(input())
for i in range(T):
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	x = ans(n, arr)
	print(x[0])
	print(x[1])


import math

def MI():
	return map(int, input().split())

def ML():
	return list(MI())

def I():
	return int(input())

def LOOP(SizE, solve):
	for XIX in range(SizE):
		solve()

def solve():
	n = I()
	a = ML()
	nd = {0: 0, 1: 0}
	for x in a:
		nd[x] += 1
	if nd[1] * 2 <= n:
		res = [0 for x in range(nd[0])]
	else:
		if nd[1] & 1:
			nd[1] -= 1
		res = [1 for x in range(nd[1])]
	print(len(res))
	print(*res)
LOOP(I(), solve)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	if A.count(0) >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	elif A.count(1) > n // 2:
		if n // 2 % 2 != 0:
			print(n // 2 + 1)
			print('1 ' * (n // 2 + 1))
		else:
			print(n // 2)
			print('1 ' * (n // 2))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	c0 = 0
	c1 = 0
	for i in l:
		if i == 0:
			c0 = c0 + 1
		else:
			c1 = c1 + 1
	if c1 % 2 == 0 and c0 % 2 == 0:
		if c1 <= n // 2:
			print(c0)
			for i in range(c0):
				print('0', end=' ')
			print()
		else:
			print(c1)
			for i in range(c1):
				print('1', end=' ')
			print()
	elif c1 == 1 and c0 == 1:
		print(1)
		print(0)
	elif c0 >= c1:
		print(c0)
		for i in range(c0):
			print(0, end=' ')
		print()
	else:
		print(c1 - 1)
		for i in range(c1 - 1):
			print(1, end=' ')
		print()


t = int(input())
for _ in range(t):
	z = 0
	ek = 0
	n = int(input())
	half = int(n / 2)
	l = list(map(int, input().split()))
	for i in range(n):
		if l[i] == 0:
			z += 1
		else:
			ek += 1
	if z > ek:
		print(half)
		for i in range(0, half):
			print('0' + ' ')
	elif ek > z:
		if n % 4 == 0:
			print(half)
			for i in range(0, half):
				print('1' + ' ')
		else:
			ad = half + 1
			print(ad)
			for i in range(0, ad):
				print('1' + ' ')
	else:
		print(half)
		for i in range(0, half):
			print('0' + ' ')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = ''.join((str(i) for i in arr))
	if s.count('1') == s.count('0'):
		print(n // 2)
		print(*list('0' * (n // 2)))
	elif s.count('0') > n // 2:
		print(n // 2)
		print(*list('0' * (n // 2)))
	elif n % 4 == 0:
		print(n // 2)
		print(*list('1' * (n // 2)))
	else:
		print(n // 2 + 1)
		print(*list('1' * (n // 2)), end=' ')
		print('1')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(s1, s2) = (sum(a[::2]), sum(a[1::2]))
	(x, y) = (a.count(0), a.count(1))
	if all((i == 0 for i in a)) or all((i == 1 for i in a)) or s1 == s2:
		print(n)
		print(*a)
	elif n == 2:
		print(1)
		print(0)
	elif x > y:
		print((n - y) // 2 * 2)
		print(*[0] * (x - (n - y) % 2))
	elif x < y:
		print((n - x) // 2 * 2)
		print(*[1] * (y - (n - x) % 2))
	else:
		print(n // 2)
		print(*[0] * (n // 2))


def print_hi(name):
	print(f'Hi, {name}')
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	s = sum(a)
	for i in range(n // 2):
		(x, y) = (a[2 * i], a[2 * i + 1])
		if [x, y] == [0, 0]:
			b += [0, 0]
		elif [x, y] == [0, 1] or [x, y] == [1, 0]:
			b += [0]
		elif [x, y] == [1, 1]:
			b += [1, 1]
	print(len(b))
	for x in b:
		print(x, end=' ')
	print()


import math, queue, heapq
import sys
sys.setrecursionlimit(10 ** 6)
fastinput = sys.stdin.readline
fastout = sys.stdout.write
t = int(fastinput())
while t:
	t -= 1
	n = int(fastinput())
	a = list(map(int, fastinput().split()))
	c = a.count(1)
	if c == 0 or c == n:
		print(n)
		print(*a)
	elif c <= n // 2:
		print(n - c)
		print('0 ' * (n - c))
	elif c % 2 == 0:
		print(c)
		print('1 ' * c)
	else:
		c -= 1
		print(c)
		print('1 ' * c)


n = int(input())
i = 0
while i < n:
	q = int(input())
	mas = input()
	if mas.count('0') < mas.count('1'):
		mas = mas.replace(' 0', '')
		mas = mas.replace('0 ', '')
		if mas.count('1') % 2 == 1:
			mas = mas[2:]
	else:
		mas = mas.replace(' 1', '')
		mas = mas.replace('1 ', '')
	mas = mas.strip()
	print(len(mas.split()))
	print(mas)
	i += 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	while len(a) > 2:
		t = sorted(a[:3])
		res.append(t[1])
		res.append(t[1])
		a = a[3:]
	if len(a) == 2:
		if a[0] == a[1]:
			res.append(a[0])
			res.append(a[1])
		else:
			res.append(0)
	print(len(res))
	print(' '.join((str(v) for v in res)))


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	n_1 = a.count(1)
	if n_1 <= n // 2:
		o = a.count(0)
		ans = [0] * o
		print(o)
		print(*ans)
	elif n_1 > n // 2 and n_1 % 2 == 0:
		ans = [1] * n_1
		print(n_1)
		print(*ans)
	else:
		print(n_1 - 1)
		ans = [1] * (n_1 - 1)
		print(*ans)
	t -= 1


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	n = ri()
	aa = rl()
	bb = []
	i = 0
	while i + 1 <= n - 1:
		if aa[i] == aa[i + 1]:
			bb.append(aa[i])
			bb.append(aa[i + 1])
			i += 2
		elif i + 2 <= n - 1:
			if aa[i + 2] == aa[i]:
				bb.append(aa[i])
				bb.append(aa[i + 2])
				i += 3
			else:
				bb.append(aa[i + 1])
				bb.append(aa[i + 2])
				i += 3
		else:
			bb.append(0)
			i += 2
	print(len(bb))
	print(*bb)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	(one, zero) = (0, 0)
	for i in a:
		if i == 0:
			zero += 1
		else:
			one += 1
	if one <= n / 2:
		print(zero)
		for i in range(zero):
			print(0, end=' ')
		print()
	else:
		if one % 2 == 1:
			one -= 1
		print(one)
		for i in range(one):
			print(1, end=' ')
		print()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	ct1 = arr.count(1)
	ct0 = arr.count(0)
	if ct0 >= n // 2:
		print(ct0)
		ans = [0] * ct0
		print(*ans)
	else:
		ct1 = ct1 - ct1 % 2
		ans = [1] * ct1
		print(len(ans))
		print(*ans)


h = int(input())
for i in range(h):
	n = int(input())
	e1 = 0
	e0 = 0
	n = list(map(int, input().split()))
	for i in range(len(n)):
		if n[i] == 1:
			e1 += 1
		else:
			e0 += 1
	if e0 >= e1:
		print(e0)
		for i in range(e0):
			print(0, end=' ')
		print()
	elif e1 % 2 == 0:
		print(e1)
		for i in range(e1):
			print(1, end=' ')
		print()
	else:
		print(e1 - 1)
		for i in range(e1 - 1):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s0 = 0
	s1 = 0
	for i in range(0, len(a)):
		if a[i] == 0:
			s0 += 1
		else:
			s1 += 1
	if s0 > len(a) // 2:
		print(len(a) // 2 + 1)
		print('0 ' * (len(a) // 2 + 1))
	elif s1 > len(a) // 2:
		if len(a) // 2 % 2 == 1:
			print(len(a) // 2 + 1)
			print('1 ' * (len(a) // 2 + 1))
		else:
			print(len(a) // 2)
			print('1 ' * (len(a) // 2))
	else:
		print(len(a) // 2)
		print('0 ' * (len(a) // 2))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	one = 0
	for i in range(n):
		if a[i] == 1:
			one += 1
	if one > n // 2:
		if one % 2 == 0:
			l = [1 for x in range(one)]
			print(len(l))
			print(*l)
		else:
			l = [1 for x in range(one - 1)]
			print(len(l))
			print(*l)
	else:
		l = [0 for x in range(n // 2)]
		print(len(l))
		print(*l)


TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	if N == 2:
		if A[0] != A[1]:
			print(1)
			print(0)
		else:
			print(2)
			print(A[0], A[1])
		continue
	c0 = 0
	c1 = 0
	for a in A:
		if a == 0:
			c0 += 1
		else:
			c1 += 1
	if c0 >= c1:
		s = 0
		c = c0
	else:
		s = 1
		if c1 % 2 != 0:
			c = c1 - 1
		else:
			c = c1
	print(c)
	for r in range(c):
		print(s, end=' ')
	print()


x = int(input())
for i in range(x):
	dlzkaPola = int(input())
	pole = list(map(int, input().split()))
	pole.append(0)
	pouzit = [True] * dlzkaPola
	kolkozostalo = dlzkaPola
	j = 0
	while j < dlzkaPola + 1:
		if pole[j] == 1:
			if pole[j + 1] == 0:
				pouzit[j] = False
				kolkozostalo -= 1
			else:
				j += 1
		j += 1
	print(kolkozostalo)
	for j in range(dlzkaPola):
		if pouzit[j]:
			print(pole[j], end=' ')
	print()


N = int(input())
Ans = []
for i in range(N):
	A = int(input())
	B = list(map(int, input().split()))
	T = []
	P = []
	m = 0
	for j in range(A):
		if B[j] == 1:
			T.append(1)
			m = j
		else:
			P.append(0)
	k = sum(T)
	h = 0
	ok = 0
	if k % 2 != 0:
		for j in range(A):
			if B[j] == 1:
				h = 1
			if h == 0:
				T.insert(0, 0)
				T.remove(1)
				ok = 1
				break
		if h == 1 and m < A - 1:
			T.append(0)
			T.remove(1)
			ok = 1
		if ok == 0:
			T = []
			l = 0
			for j in range(A):
				if B[j] == 1:
					T.append(1)
				if j + 1 < A:
					if B[j] == 0 and B[j + 1] == 0 and (l == 0):
						T.append(0)
						T.append(0)
						l = 1
			T.remove(1)
	if len(T) >= 2 and k > A // 2:
		Ans.append([len(T), T])
	else:
		Ans.append([len(P), P])
for i in Ans:
	print(i[0])
	for j in i[1]:
		print(j, end=' ')
	print()


import sys
import itertools
import math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	m -= 1
	(n,) = I()
	arr = I()
	c = 0
	z = o = 0
	for i in range(n):
		if arr[i] == 0:
			z += 1
		else:
			o += 1
	if o <= n // 2:
		print(z)
		print(*[0] * z)
	elif z <= n // 2:
		if o % 2:
			print(o - 1)
			print(*[1] * (o - 1))
		else:
			print(o)
			print(*[1] * o)


T = int(input())
ret = []
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	count = [0] * 2
	for i in range(n):
		count[a[i]] += 1
	if count[0] < count[1]:
		le = count[1] - count[1] % 2
		ans = [le, ['1' for i in range(le)]]
	else:
		ans = [count[0], ['0' for i in range(count[0])]]
	ret.append(ans)
for t in range(T):
	print(ret[t][0])
	print(' '.join(ret[t][1]))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [ai for ai in input().split()]
	(oc, zc) = (0, 0)
	for ai in a:
		oc += ai == '1'
		zc += ai == '0'
	if oc > zc:
		oc -= oc % 2
		print(oc)
		for i in range(0, oc):
			print(1, end=' ')
		print()
		continue
	if zc > oc:
		print(zc)
		for i in range(0, zc):
			print(0, end=' ')
		print()
		continue
	(oc, zc) = (oc - oc % 2, oc % 2)
	if not zc:
		print(oc)
		for i in range(0, oc):
			print(1, end=' ')
		print()
		continue
	if a[0] == '0':
		print(oc + 1)
		print(0, end=' ')
		for i in range(0, oc):
			print(1, end=' ')
		print()
		continue
	if a[1] == '0':
		print(oc + 1)
		print(0, end=' ')
		for i in range(0, oc):
			print(1, end=' ')
		print()
		continue
	if a[-1] == '0':
		print(oc + 1)
		for i in range(0, oc):
			print(1, end=' ')
		print(0)
		continue
	if a[-2] == '0':
		print(oc + 1)
		for i in range(0, oc):
			print(1, end=' ')
		print(0)
		continue
	print(oc + 2)
	zc = 2
	for i in range(0, len(a)):
		if a[i] == '0' and zc:
			print(0, end=' ')
			zc -= 1
			continue
		if a[i] == '1' and oc:
			print(1, end=' ')
			oc -= 1
			continue
	print()
	continue
	zao = a[n - 1] == '0'
	print(oc + zc)
	for ai in a:
		if ai == '0':
			if zc and oc % 2 == 0:
				print(0, end=' ')
				zc -= 1
			continue
		if ai == '1':
			if oc:
				print(1, end=' ')
				oc -= 1
			continue
	print()


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	(z, o) = (0, 0)
	for i in l:
		if i == 0:
			z += 1
		else:
			o += 1
	if z == n or o == n:
		return l
	if z == o:
		return [0] * z
	if z > o:
		if z % 2 == 0:
			return [0] * z
		else:
			z -= 1
			return [0] * z
	elif o % 2 == 0:
		return [1] * o
	else:
		o -= 1
		return [1] * o
for _ in range(int(input())):
	p = solve()
	print(len(p))
	print(*p)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = [0, 0]
	for i in arr:
		d[i] += 1
	if d[0] >= d[1]:
		print(d[0])
		print('0 ' * d[0])
	else:
		k = d[1] - d[1] % 2
		print(k)
		print('1 ' * k)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(n - 1):
		if i & 1:
			continue
		if a[i] == 1 and a[i + 1] == 1:
			ans.append(1)
			ans.append(1)
		elif a[i] == 0 and a[i + 1] == 0:
			ans.append(0)
			ans.append(0)
		else:
			ans.append(0)
	print(len(ans))
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt0 = 0
	cnt1 = 0
	for val in a:
		if val == 0:
			cnt0 += 1
		else:
			cnt1 += 1
	if cnt0 >= cnt1:
		print(cnt0)
		print('0 ' * cnt0)
	elif cnt1 % 2 == 0:
		print(cnt1)
		print('1 ' * cnt1)
	else:
		print(cnt1 - 1)
		print('1 ' * (cnt1 - 1))


for t in range(int(input())):
	n = int(input())
	nums = [int(x) for x in input().split()]
	res = []
	for i in range(n // 4):
		(a, b) = (nums[4 * i] + nums[4 * i + 2], nums[4 * i + 1] + nums[4 * i + 3])
		if a == b:
			res.extend(nums[4 * i:4 * i + 4])
		elif a == 0 or b == 0:
			res.append(0)
			res.append(0)
		elif a == 2 or b == 2:
			res.append(1)
			res.append(1)
	if n % 4:
		if nums[-1] == nums[-2]:
			res.append(nums[-2])
			res.append(nums[-1])
		else:
			res.append(0)
	print(len(res))
	print(*res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cone = sum(a)
	czero = n - cone
	if cone <= n // 2:
		print(czero)
		print(*[0] * czero)
	elif cone % 2 == 0:
		print(cone)
		print(*[1] * cone)
	else:
		print(cone - 1)
		print(*[1] * (cone - 1))


def gt():
	return list(map(int, input().split()))
(t,) = gt()
while t:
	t -= 1
	(n,) = gt()
	ar = gt()
	one = sum(ar)
	if one <= n // 2:
		leng = n // 2
		print(leng)
		print(*[0 for i in range(leng)])
	else:
		leng = n // 2 + (n // 2 & 1)
		print(leng)
		print(*[1 for i in range(leng)])


import math
from collections import defaultdict, deque
from itertools import permutations
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : list(input())
ips = lambda : input().split()
t = ii()
for _ in range(t):
	n = ii()
	a = ll()
	b = a.count(1)
	c = a.count(0)
	k = 1
	if b > n // 2:
		cnt = 0
		if n // 2 & 1:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ')
		else:
			print(n // 2)
			for i in range(n // 2):
				print(1, end=' ')
	else:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
	print()


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		n = n // 2
		no1 = l.count(1)
		if no1 <= n:
			print(n)
			for x in range(n):
				print(0, end=' ')
			print()
			return
		elif no1 >= n and n & 1 != 1:
			print(n)
			for x in range(n):
				print(1, end=' ')
			print()
			return
		else:
			if n & 1 == 1 and no1 >= n + 1:
				print(n + 1)
				for x in range(n + 1):
					print(1, end=' ')
				print()
				return
			no0 = 0
			x = 0
			ans = []
			while x < 2 * n:
				if l[x] == 0:
					no0 += 1
					x += 1
				elif no0 >= 1:
					ans.append(0)
					ans.append(1)
					x += 1
					no0 -= 1
				elif l[x + 1] == 1:
					ans.append(1)
					ans.append(1)
					x += 2
				else:
					ans.append(1)
					ans.append(0)
					x += 2
			print(len(ans))
			print(*ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = 0
	i = 0
	j = 1
	l = []
	while i < n and j < n:
		if a[i] != a[j]:
			s = 0
			if j + 1 < n:
				s = a[j + 1]
			if a[i] == s:
				l.append(a[i])
			else:
				l.append(a[j])
				i = j
			k = k + 1
			if j + 1 < n:
				j = j + 1
				l.append(a[j])
			i = j + 1
			j = j + 2
		else:
			l.append(a[i])
			l.append(a[j])
			i = i + 2
			j = j + 2
	if i < n:
		if a[i] == 0:
			l.append(a[i])
		else:
			k = k + 1
	print(len(l))
	for i in range(0, len(l)):
		print(l[i], end=' ')
	print()


testCases = int(input())
for i in range(testCases):
	zeroCount = 0
	oneCount = 0
	n = int(input())
	input1 = list(map(int, input().split(' ')))
	for i in range(0, n):
		if input1[i] == 1:
			oneCount += 1
		else:
			zeroCount += 1
	if oneCount <= n / 2:
		print(zeroCount)
		for i in range(0, zeroCount):
			print('0 ', end='')
		print()
	else:
		var = oneCount // 2 * 2
		print(var)
		for i in range(0, var):
			print('1 ', end='')
		print()


def f(ayes):
	n = len(ayes)
	cnt1 = len([a for a in ayes if a])
	cnt0 = n - cnt1
	if cnt1 <= n // 2:
		return [0 for _ in range(cnt0)]
	else:
		return [1 for _ in range(cnt1 - cnt1 % 2)]
t = int(input())
for _ in range(t):
	_ = int(input())
	result = f([int(a) for a in input().split()])
	print(len(result))
	print(' '.join([str(x) for x in result]))


for i in ' ' * int(input()):
	n = int(input())
	L = list(map(int, input().split()))
	s = sum(L)
	if s * 2 > n:
		if n // 2 % 2:
			print(n // 2 + 1)
			for i in ' ' * (n // 2 + 1):
				print(1, end=' ')
		else:
			print(n // 2)
			for i in ' ' * (n // 2):
				print(1, end=' ')
	else:
		print(n // 2)
		for i in ' ' * (n // 2):
			print(0, end=' ')
	print()


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	a = li()
	c = 0
	d = 0
	for i in range(n):
		if a[i]:
			c += 1
		else:
			d += 1
	if c > d:
		print(c - c % 2)
		c -= c % 2
		for i in range(n):
			if a[i] and c:
				c -= 1
				print(a[i], end=' ')
	else:
		print(d)
		for i in range(n):
			if not a[i]:
				print(a[i], end=' ')
	print()
for _ in range(I()):
	solve()


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	on = lis.count(1)
	ze = lis.count(0)
	if n == 2 and ze == 1 and (on == 1):
		print(1)
		print(0)
	elif ze == on:
		print(n // 2)
		print('0 ' * (n // 2))
	elif ze > on:
		print(n // 2)
		print('0 ' * (n // 2))
	elif n % 4 == 0:
		print(n // 2)
		print('1 ' * (n // 2))
	else:
		print(n // 2 + 1)
		print('1 ' * (n // 2 + 1))


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ic = 0
	oc = 0
	for i in arr:
		if i == 1:
			ic += 1
		else:
			oc += 1
	if ic > oc:
		if ic % 2 == 0:
			print(ic)
			print('1 ' * ic)
		else:
			print(ic - 1)
			print('1 ' * (ic - 1))
	else:
		print(oc)
		print('0 ' * oc)


t = int(input())
for i in range(t):
	n = int(input())
	k = list(map(int, input().split(' ')))
	if sum(k) <= n // 2:
		print(n - sum(k))
		print('0 ' * (n - sum(k)))
	elif sum(k) > n // 2:
		if n // 2 % 2 == 0:
			print(n // 2)
			print('1 ' * (n // 2))
		else:
			print(n // 2 + 1)
			print('1 ' * (n // 2 + 1))


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		a = ain()
		cz = 0
		co = 0
		for i in a:
			if i == 0:
				cz += 1
			else:
				co += 1
		if cz >= n // 2:
			print(cz)
			l = [0] * cz
		elif co % 2 == 1:
			l = [1] * (co - 1)
			print(co - 1)
		else:
			l = [1] * co
			print(co)
		print(*l)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	o = 0
	for i in a:
		if i == 1:
			o += 1
	if o > n - o:
		if o % 2 == 0:
			print(o)
			print(*[1] * o)
		else:
			print(o - 1)
			print(*[1] * (o - 1))
	else:
		print(n - o)
		print(*[0] * (n - o))


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(c1, c0) = (l.count(1), l.count(0))
	if c0 >= c1:
		ans = [0] * (n // 2)
	elif n // 2 & 1:
		ans = [1] * (n // 2 + 1)
	else:
		ans = [1] * (n // 2)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	zero = arr.count(0)
	one = n - zero
	if one * 2 <= n:
		print(zero)
		print(*[0] * zero)
	else:
		if one % 2 == 1:
			one -= 1
		print(one)
		print(*[1] * one)


import math, sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	i = 0
	B = []
	while i < n:
		if A[i] == 1:
			j = i + 1
			while j < n and A[j] != 1:
				j = j + 1
			if j != n and (j - i) % 2 != 0:
				for k in range(i, j + 1):
					B.append(A[k])
				i = j + 1
			else:
				for k in range(i + 1, j):
					B.append(A[k])
				i = j
		else:
			B.append(A[i])
			i = i + 1
	print(len(B))
	print(*B)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj
import sys
import threading
from math import *
sys.setrecursionlimit(300000)
threading.stack_size(10 ** 8)

def pow_of_3(x):
	ans = 0
	while x % 3 == 0:
		ans += 1
		x //= 3
	return ans
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = a.count(0)
	if z >= n // 2:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		size = n // 2
		size += size & 1
		print(size)
		print(*[1] * size)


t = int(input())
for i in range(t):
	(n, a) = (int(input()), list(map(int, input().split())))
	(count1, count0) = (0, 0)
	for i in range(n):
		if a[i] == 0:
			count0 += 1
		else:
			count1 += 1
	if count0 >= count1:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
	else:
		k = n // 2
		if k % 2 == 0:
			print(k)
			for i in range(k):
				print(1, end=' ')
		else:
			print(k + 1)
			for i in range(k + 1):
				print(1, end=' ')
	print()


n = int(input())
for _ in range(n):
	a = int(input())
	b = list(map(int, input().split()))
	if a % 4 != 0:
		c = a + (4 - a % 4)
	else:
		c = a
	c //= 2
	if b.count(1) >= c:
		print(c)
		print('1 ' * c)
	else:
		print(a // 2)
		print('0 ' * (a // 2))


t = lambda : range(int(input()))
a = lambda : list(map(int, input().split()))
for _ in t():
	n = int(input())
	p = a()
	op = []
	for i in range(0, len(p) - 1, 2):
		x = abs(p[i] - p[i + 1])
		if not x:
			op.append(p[i])
			op.append(p[i + 1])
		else:
			op.append(0)
	print(len(op))
	for j in op:
		print(j, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	first = []
	second = []
	zeroes = a.count(0)
	ones = a.count(1)
	if zeroes % 2:
		if ones - 1 >= n // 2:
			print(ones - 1)
			print(*[1 for i in range(ones - 1)])
		else:
			print(zeroes)
			print(*[0 for i in range(zeroes)])
	elif zeroes > ones:
		print(zeroes)
		print(*[i for i in a if i == 0])
	else:
		print(ones)
		print(*[i for i in a if i == 1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	x = 0
	ones = a.count(1)
	if ones <= n / 2:
		print(n - ones)
		print(' '.join(('0' for i in range(n - ones))))
	elif ones % 2 == 0:
		print(ones)
		print(' '.join(('1' for i in range(ones))))
	else:
		print(ones - 1)
		print(' '.join(('1' for i in range(ones - 1))))


def ans():
	N = int(input())
	for i in range(N):
		A = int(input())
		arr = input().split()
		a = 0
		b = 0
		for j in range(A):
			if arr[j] == '1':
				a += 1
			elif arr[j] == '0':
				b += 1
		if a > b:
			if len(arr) // 2 % 2 == 0:
				print(len(arr) // 2)
				for k in range(len(arr) // 2):
					if k != len(arr) // 2 - 1:
						print(1, end=' ')
					else:
						print(1)
			else:
				print(len(arr) // 2 + 1)
				for k in range(len(arr) // 2):
					if k != len(arr) // 2 - 1:
						print(1, end=' ')
					else:
						print(1, end=' ')
						print(1)
		else:
			print(len(arr) // 2)
			for k in range(len(arr) // 2):
				if k != len(arr) // 2 - 1:
					print(0, end=' ')
				else:
					print(0)
ans()


for tt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(0) >= n // 2:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		print(a.count(1) - a.count(1) % 2)
		print(*[1] * (a.count(1) - a.count(1) % 2))


from queue import PriorityQueue
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	(o, z) = (0, 0)
	for i in ar:
		if i == 0:
			z += 1
		else:
			o += 1
	p = n // 2
	if p % 2 == 0:
		if z > o:
			print(z)
			print('0 ' * z)
		elif o > z:
			print(p)
			print('1 ' * p)
		else:
			print(z)
			print('0 ' * z)
	elif z > o:
		print(z)
		print('0 ' * z)
	elif o > z:
		print(p + 1)
		print('1 ' * (p + 1))
	elif z == o:
		print(z)
		print('0 ' * z)


for _ in range(int(input())):
	(n, lst) = (int(input()), input())
	(count0, count1) = (lst.count('0'), lst.count('1'))
	if count0 >= n / 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
	else:
		print(count1 - (count1 & 1))
		for i in range(count1 - (count1 & 1)):
			print(1, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	ai = list(map(int, input().split()))
	ans = []
	for i in range(n // 2):
		if ai[i * 2] == ai[i * 2 + 1]:
			ans += [ai[i * 2], ai[i * 2]]
		else:
			ans += [0]
	print(len(ans))
	print(' '.join(map(str, ans)))


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		(one, zr) = (0, 0)
		for i in ar:
			if i == 1:
				one += 1
			else:
				zr += 1
		if one > zr:
			if one > 1 and one % 2 == 1:
				one -= 1
			print(one)
			print('1 ' * one)
		else:
			print(zr)
			print('0 ' * zr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import deque, defaultdict, Counter, OrderedDict
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c_d = dict(Counter(arr))
	zeros = c_d.get(0, 0)
	ones = c_d.get(1, 0)
	if ones % 2 == 0 and ones >= len(arr) // 2:
		print(ones)
		for ka in range(0, ones):
			print('1', end=' ')
	elif (ones - 1) % 2 == 0 and ones - 1 >= len(arr) // 2:
		print(ones - 1)
		for ka in range(0, ones - 1):
			print('1', end=' ')
	else:
		print(zeros)
		for ka in range(0, zeros):
			print('0', end=' ')
	print()


x = int(input())
ans = []
for k in range(x):
	n = int(input())
	a = list(map(int, input().split()))
	kln = 0
	for i in range(n):
		if a[i] == 0:
			kln += 1
	if kln >= n // 2:
		ans.append([0] * kln)
	else:
		kle = 0
		for i in range(n):
			if a[i] == 1:
				kle += 1
		if kle % 2 == 1:
			ans.append([1] * (kle - 1))
		else:
			ans.append([1] * kle)
for i in range(len(ans)):
	print(len(ans[i]))
	print(*ans[i])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	o = sum(arr)
	z = n - o
	if z >= int(n / 2):
		print(int(n / 2))
		ans = [0] * int(n / 2)
	elif o % 2 == 0:
		print(o)
		ans = [1] * o
	else:
		print(o - 1)
		ans = [1] * (o - 1)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = l.count(0)
	f = l.count(1)
	if c >= f:
		print(n // 2)
		for _ in range(n // 2):
			print(0, end=' ')
	else:
		if n // 2 % 2 != 0:
			n = n + 2
		print(n // 2)
		for _ in range(n // 2):
			print(1, end=' ')
	print('')


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = input().rstrip().split()
	it = iter(a)
	ans = []
	for __ in range(n // 2):
		(a1, a2) = (next(it), next(it))
		if a1 == '0' and a2 == '1' or (a1 == '1' and a2 == '0'):
			ans.append('0')
		else:
			ans.append(a1)
			ans.append(a2)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0, 0]
	for i in range(n):
		cnt[a[i]] += 1
	take = 0 if cnt[0] >= cnt[1] else 1
	ans = []
	for i in range(n):
		if len(ans) % 2 == 0 and len(ans) >= n // 2:
			break
		if a[i] == take:
			ans.append(str(a[i]))
	print(len(ans))
	print(' '.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = sum([a[i] for i in range(0, n, 2)])
	c = sum([a[i] for i in range(1, n, 2)])
	if b == c:
		if b == 0:
			print(n // 2)
			print(*[0 for i in range(n // 2)])
		else:
			print(n)
			print(*a)
	elif a.count(0) < n // 2:
		b = [int(i) for i in a if i != 0]
		if len(b) % 2 != 0:
			print(max(len(b) - 1, 1))
			if max(len(b) - 1, 1) == 1:
				print(0)
			else:
				print(*b[1:])
		else:
			print(len(b))
			print(*b)
	else:
		print(a.count(0))
		print(*[0 for i in range(a.count(0))])


t = int(input())
for _ in range(t):
	cnt0 = 0
	n = int(input())
	arr = list(map(int, input().split()))
	for i in range(n):
		if arr[i] == 0:
			cnt0 += 1
	cnt1 = n - cnt0
	if cnt0 >= n // 2:
		print(cnt0)
		for i in range(cnt0):
			print(0, end=' ')
		print()
	else:
		print(cnt1 - cnt1 % 2)
		for i in range(cnt1 - cnt1 % 2):
			print(1, end=' ')
		print()


import sys
input = sys.stdin.buffer.readline
T = int(input())
for testcase in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	z = 0
	for e in a:
		if e == 0:
			z += 1
	m = n // 2
	if z >= m:
		print(m)
		print(*list([0] * m))
	elif m % 2 == 0:
		print(m)
		print(*list([1] * m))
	else:
		print(m + 1)
		print(*list([1] * (m + 1)))


for __ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	one_count = 0
	for q in l:
		if q == 1:
			one_count += 1
	zero_count = n - one_count
	if one_count <= n // 2:
		print(n // 2)
		for q in range(n // 2):
			print(0, end=' ')
		print()
	elif one_count % 2:
		print(one_count - 1)
		for i in range(one_count - 1):
			print(1, end=' ')
		print()
	else:
		print(one_count)
		for q in range(one_count):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s > n // 2:
		if s % 2 == 1:
			s -= 1
		print(s)
		print('1 ' * s)
	else:
		print(n - s)
		print('0 ' * (n - s))


t = int(input())
while t > 0:
	n = int(input())
	arr = [int(i) for i in input().split()]
	zero = one = 0
	for i in arr:
		if i == 0:
			zero += 1
		else:
			one += 1
	if one <= zero:
		print(zero)
		for i in range(zero):
			print(0, end=' ')
		print()
	elif one % 2 != 0:
		print(one - 1)
		for i in range(n):
			if arr[i] == 0:
				continue
			elif one - 1:
				print(1, end=' ')
				one -= 1
		print()
	else:
		print(one)
		for i in range(one):
			print(1, end=' ')
		print()
	t -= 1


for i in range(int(input())):
	n = int(input())
	a = input().split()
	a = a[0:n]
	k = 0
	oneC = a.count('1')
	if oneC > n // 2:
		if n // 2 % 2 == 0:
			k = n // 2
		else:
			k = n // 2 + 1
		print(k)
		print(' '.join(['1' for i in range(k)]))
	else:
		print(n // 2)
		print(' '.join(['0' for i in range(n // 2)]))


import os
import sys
from io import BytesIO, IOBase
import threading
from collections import defaultdict
from math import gcd

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	r = -1
	rp = 0
	for i in range(n):
		if arr[i] == 0:
			ans.append(0)
		elif len(ans) % 2 == rp:
			rp += 1
			rp %= 2
			r = len(ans)
			ans.append(1)
	if sum(ans) % 2:
		ans = ans[:r] + ans[r + 1:]
	if len(ans) < n // 2:
		r = -1
		rp = 1
		ans = []
		for i in range(n):
			if arr[i] == 0:
				ans.append(0)
			elif len(ans) % 2 == rp:
				rp += 1
				rp %= 2
				r = len(ans)
				ans.append(1)
		if sum(ans) % 2:
			ans = ans[:r] + ans[r + 1:]
	print(len(ans))
	print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(int(input())):
	main()


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	o = a.count('1')
	z = n - o
	half = n >> 1
	if o > z:
		if half & 1:
			half += 1
			print(half)
			print('1 ' * half)
		else:
			print(half)
			print('1 ' * half)
	else:
		print(half)
		print('0 ' * half)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	ek = li.count(1)
	sunno = n - ek
	if sunno >= n // 2:
		print(sunno)
		print(*[0] * sunno)
	else:
		ek -= ek % 2
		print(ek)
		print(*[1] * ek)


def solve(arr: list):
	ones = 0
	zeros = 0
	for i in range(len(arr)):
		if arr[i] == 1:
			ones += 1
		else:
			zeros += 1
	if ones > zeros:
		if ones % 2 != 0:
			ones -= 1
		print(ones)
		print(' '.join(['1' for _ in range(ones)]))
	else:
		print(zeros)
		print(' '.join(['0' for _ in range(zeros)]))
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	solve(arr)


import sys
input = sys.stdin.buffer.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	one = alst.count(1)
	zero = alst.count(0)
	if zero * 2 >= n:
		print(zero)
		ans = [0] * zero
		print(*ans)
	elif one % 2 == 0:
		print(one)
		ans = [1] * one
		print(*ans)
	else:
		print(one - 1)
		ans = [1] * (one - 1)
		print(*ans)
for _ in range(int(input())):
	main()


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	j = 0
	tot = 0
	s = 0
	if sum(arr) % 2 != 0:
		while j < len(arr):
			if arr[j] == 1:
				del arr[j]
				break
			j += 1
	while j < len(arr):
		if arr[j] == 1:
			if tot == 0:
				tot = 1
			else:
				if s % 2 != 0:
					del arr[j - 1]
					j -= 1
				tot = 0
			s = 0
		else:
			s += 1
		j += 1
	print(len(arr))
	for j in arr:
		print(j, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	zero = a.count(0)
	if zero >= n // 2:
		print(zero)
		print(*[0 for i in range(zero)])
	else:
		one = a.count(1)
		if one % 2:
			print(one - 1)
			print(*[1 for i in range(one - 1)])
		else:
			print(one)
			print(*[1 for i in range(one)])


def alt_sum(A):
	a = 0
	b = 0
	for i in range(len(A)):
		if i % 2 == 0:
			a += A[i]
		else:
			b += A[i]
	return (a, b)

def ans(A):
	n = len(A)
	while True:
		(a, b) = alt_sum(A)
		if a == b:
			assert len(A) >= n // 2
			print(len(A))
			print(*A)
			return
		if a > b:
			aa = 0
			bb = 0
			for i in range(len(A) - 1, -1, -1):
				if i % 2 == 0:
					aa += A[i]
				else:
					bb += A[i]
				if i % 2 == 0 and A[i] == 1 and (aa > bb):
					del A[i]
					break
		elif b > a:
			aa = 0
			bb = 0
			for i in range(len(A) - 1, -1, -1):
				if i % 2 == 0:
					aa += A[i]
				else:
					bb += A[i]
				if i % 2 == 1 and A[i] == 1 and (bb > aa):
					del A[i]
					break
		else:
			assert False
if False:
	import random, sys
	for _ in range(100000):
		test_case = [random.choice([0, 1]) for _ in range(6)]
		print('tc=', test_case)
		ans(test_case)
	sys.exit(0)
T = int(input())
for t in range(T):
	input()
	A = list(map(int, input().split()))
	ans(A)


m = int(input())
for i in range(m):
	n = int(input())
	a = list(map(int, input().split(' ')))
	if a.count(1) >= n // 2:
		if n == 2:
			if a.count(1) == 2:
				print(n)
				print(*(1 for w in range(2)))
			else:
				print(n // 2)
				print(0)
		elif n // 2 % 2 != 0:
			if a.count(1) > n // 2:
				print(n // 2 + 1)
				print(*(1 for lll in range(n // 2 + 1)))
			else:
				print(n // 2)
				print(*(0 for kk in range(n // 2)))
		else:
			print(n // 2)
			print(*(1 for nn in range(n // 2)))
	else:
		print(n // 2)
		print(*(0 for nm in range(n // 2)))


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	z = lis.count(0)
	o = lis.count(1)
	if z >= o:
		print(z)
		print(*[0] * z)
	else:
		print(o - o % 2)
		print(*[1] * (o - o % 2))


import sys
import math as mt
import collections as cc
import sys
import itertools as it
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	a = 0
	b = 0
	a0 = []
	a1 = []
	b0 = []
	b1 = []
	for i in range(0, n, 2):
		a += l[i]
		if l[i] == 0:
			a0.append(i)
		else:
			a1.append(i)
	for j in range(1, n, 2):
		b += l[i]
		if l[i] == 0:
			b0.append(i)
		else:
			b1.append(i)
	i = 0
	ans = []
	while i < n - 1:
		if l[i] == 1 and l[i + 1] == 1:
			ans.append(l[i])
			ans.append(l[i])
			i += 2
		elif l[i] == 1 and l[i + 1] == 0:
			ans.append(l[i + 1])
			i += 2
		elif l[i] == 0 and l[i + 1] == 0:
			ans.append(l[i])
			ans.append(l[i + 1])
			i += 2
		elif l[i] == 0 and l[i + 1] == 1:
			ans.append(l[i])
			i += 1
	print(len(ans))
	print(*ans)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	lol = l[0]
	cou = 0
	i = 0
	res = []
	while i < n - 2:
		if l[i] == l[i + 1]:
			res.append(l[i])
			res.append(l[i])
			i += 2
		elif l[i] == l[i + 2]:
			res.append(l[i])
			res.append(l[i])
			i += 3
		elif l[i + 1] == l[i + 2]:
			res.append(l[i + 1])
			res.append(l[i + 1])
			i += 3
	if i == n - 2:
		if l[i] == l[i + 1]:
			res.append(l[i])
			res.append(l[i])
	if len(res) == 0:
		print(1)
		print(0)
	else:
		print(len(res))
		print(*res)
	t -= 1


t = int(input())
for i2 in range(t):
	n = int(input())
	dem = n
	d = 0
	d2 = 0
	a = [int(i) for i in input().split()]
	for i in a:
		if i == 0:
			d += 1
		else:
			d2 += 1
	if d >= n // 2:
		print(d)
		for i in range(d):
			print(0, end=' ')
	else:
		if d2 % 2 == 1:
			d2 -= 1
		print(d2)
		for i in range(d2):
			print(1, end=' ')
	print()


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	C = Counter(A)
	if C[0] < C[1]:
		ans = []
		for i in range(N):
			if A[i] == 1:
				ans.append(1)
		if len(ans) % 2 == 1:
			ans.pop()
		print(len(ans))
		print(*ans)
	else:
		ans = []
		for i in range(N):
			if A[i] == 0:
				ans.append(0)
		print(len(ans))
		print(*ans)


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	n = iinput()
	a = linput()
	zeros = a.count(0)
	ones = n - zeros
	if zeros >= n // 2:
		print(zeros)
		print(*[0] * zeros)
	else:
		if ones & 1:
			ones -= 1
		print(ones)
		print(*[1] * ones)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	ans = []
	while i < n:
		if l[i] == l[i + 1]:
			ans.append(l[i])
			ans.append(l[i])
			i += 2
		elif i + 3 < n:
			if l[i] == l[i + 2] or l[i] == l[i + 3]:
				ans.append(l[i])
				ans.append(l[i])
				i += 4
			elif l[i + 1] == l[i + 2] or l[i + 1] == l[i + 3]:
				ans.append(l[i + 1])
				ans.append(l[i + 1])
				i += 4
		elif l[i] == 0 or l[i + 1] == 0:
			ans.append(0)
			i += 2
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


import sys
import math
from math import *
from collections import Counter, defaultdict, deque
sys.setrecursionlimit(10 ** 9)
lip = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input().split()

def main():
	n = ip()
	arr = lip()
	ans = []
	i = 0
	while i < n:
		o = 2
		z = 2
		while i < n and o and z:
			if arr[i]:
				o -= 1
			else:
				z -= 1
			i += 1
		if not o:
			ans += [1, 1]
		if not z:
			ans += [0, 0]
	if len(ans) < n // 2:
		ans.append(0)
	print(len(ans))
	print(*ans)
for i in range(ip()):
	main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	odd = 0
	even = 0
	i = 0
	ans = []
	while i < n:
		j = i + 1
		if a[i] == 0:
			ans.append(0)
		else:
			while j < n and a[j]:
				j += 1
			count = j - i
			if count % 2:
				count -= 1
			while count > 0:
				ans.append(1)
				count -= 1
		i = j
	print(len(ans))
	print(*ans)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	L = list(map(int, input().split()))
	zero = L.count(0)
	if zero >= n / 2:
		print(zero)
		print(*[0] * zero)
		return
	one = n - zero
	print(one // 2 * 2)
	print(*[1] * (one // 2 * 2))
for _ in range(int(input())):
	solve()


from sys import stdin

def readline():
	return stdin.readline()

def solve(n, a):
	arr = []
	k = 0
	i = 1
	while i < n:
		if a[i - 1] == a[i]:
			k += 2
			arr.append(a[i - 1])
			arr.append(a[i])
			i += 2
		elif i < n - 1 and a[i - 1] == a[i + 1]:
			k += 2
			arr.append(a[i - 1])
			arr.append(a[i + 1])
			i += 3
		elif i < n - 1 and a[i] == a[i + 1]:
			k += 2
			arr.append(a[i])
			arr.append(a[i + 1])
			i += 3
		else:
			k += 1
			i += 1
			arr.append(0)
	print(k)
	return ' '.join(map(str, arr))
tests = int(readline())
for t in range(0, tests):
	n = int(readline())
	a = list(map(int, readline().rstrip('\n').split(' ')))
	print(solve(n, a))


for j in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnt0 = 0
	cnt1 = 0
	for i in range(n):
		if a[i] == 0:
			cnt0 += 1
		else:
			cnt1 += 1
	if cnt1 > cnt0:
		print(cnt1 if cnt1 % 2 == 0 else cnt1 - 1)
		for i in range(cnt1 if cnt1 % 2 == 0 else cnt1 - 1):
			print('1', end=' ')
	else:
		print(cnt0)
		for i in range(cnt0):
			print('0', end=' ')
	print()


import sys
input = lambda : sys.stdin.readline()
for _ in range(int(input())):
	n = int(input())
	a = ''.join(list(map(str, input().split())))
	one = a.count('1')
	zer = a.count('0')
	if one > n // 2:
		if n // 2 % 2 == 1:
			n += 2
		print(n // 2)
		print(*[1 for i in range(n // 2)])
	else:
		print(n // 2)
		print(*[0 for i in range(n // 2)])


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	n = II()
	a = L()
	(cnt_0, cnt_1) = (a.count(0), a.count(1))
	if cnt_0 >= cnt_1:
		print(cnt_0)
		li = [0] * cnt_0
		print(*li)
	elif cnt_1 % 2 == 0:
		print(cnt_1)
		li = [1] * cnt_1
		print(*li)
	else:
		print(cnt_1 - 1)
		li = [1] * (cnt_1 - 1)
		print(*li)
	return
t = II()
for i in range(t):
	solve()


for tc in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	zeros = arr.count(0)
	ones = arr.count(1)
	if ones <= n // 2:
		print(zeros)
		print(*[0] * zeros)
	elif ones % 2 == 0:
		print(ones)
		print(*[1] * ones)
	else:
		print(ones - 1)
		print(*[1] * (ones - 1))


import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter
import sys
readline = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(readline())

def read_int_n():
	return list(map(int, readline().split()))

def read_float():
	return float(readline())

def read_float_n():
	return list(map(float, readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def ep(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.perf_counter()
		ret = f(*args, **kwargs)
		e = time.perf_counter()
		ep(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(N, A):
	s = sum(A[::2]) - sum(A[1::2])
	if s == 0:
		ans = A
	else:
		ss = 0
		for i in range(N):
			if i % 2 == 0:
				v = A[i]
			else:
				v = -A[i]
			if ss == s - ss - v:
				ans = A[:i] + A[i + 1:]
			ss += v
	print(len(ans))
	print(*ans)

def main():
	for _ in range(read_int()):
		N = read_int()
		A = read_int_n()
		slv(N, A)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = a.count(1)
	q = a.count(0)
	if p > q:
		t = n // 2
		if t % 2 == 0:
			print(t)
			r = ['1'] * (n // 2)
			print(' '.join(r))
		else:
			print(t + 1)
			r = ['1'] * (t + 1)
			print(' '.join(r))
	elif p < q:
		print(n // 2)
		r = ['0'] * (n // 2)
		print(' '.join(r))
	else:
		print(n // 2)
		r = ['0'] * (n // 2)
		print(' '.join(r))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	(z, o) = (0, 0)
	if 0 in A:
		z = A.count(0)
	if 1 in A:
		o = A.count(1)
	if o % 2:
		o -= 1
	print(max(z, o))
	if z >= o:
		for i in range(z):
			print(0, end=' ')
	else:
		for i in range(o):
			print(1, end=' ')
	print()


from collections import Counter
import sys

def main():
	t = Iint()
	for _ in range(t):
		n = Iint()
		a = Ilist()
		ca = Counter(a)
		(ca0, ca1) = (ca[0], ca[1])
		if ca0 >= n // 2:
			k = n // 2
			print(k)
			Plist([0] * k)
		elif ca1 > n // 2:
			k = ca1 - ca1 % 2
			print(k)
			Plist([1] * k)
en = enumerate
FIO = 10

def debug(*args, c=6):
	pass
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=sys.stderr)
BUFSIZE = 8 * 1024

def Istr():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import os

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	ones = 0
	zeros = 0
	for j in a:
		if j == 1:
			ones += 1
		else:
			zeros += 1
	if zeros >= n / 2:
		print(zeros)
		z = [0 for k in range(zeros)]
		print(*z, sep=' ')
	else:
		o = [1 for h in range(ones)]
		if ones % 2 == 0:
			print(ones)
			print(*o, sep=' ')
		else:
			o.remove(1)
			print(len(o))
			print(*o, sep=' ')


import math
for i in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count_zero = 0
	count_one = 0
	for j in a:
		if j == 0:
			count_zero += 1
		else:
			count_one += 1
	if count_zero >= count_one:
		print(count_zero)
		for k in range(0, len(a)):
			if a[k] == 0:
				print(a[k], end=' ')
	else:
		flag = 0
		if count_one % 2:
			flag = 1
			count_one -= 1
		print(count_one)
		for k in range(0, len(a)):
			if a[k] == 1:
				if flag == 1:
					flag = 0
					continue
				print(a[k], end=' ')
	print()


from sys import stdin, stdout

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(input())):
			n = int(R())
			a = R()
			zero = a.count('0')
			one = a.count('1')
			one -= one % 2
			if zero >= n // 2:
				ans += [str(zero), '\n', '0 ' * zero, '\n']
			else:
				ans += [str(one), '\n', '1 ' * one, '\n']
		W(''.join(ans))

def main():
	s = SOLVE()
	s.solve()
main()


otv = []
for i in range(int(input())):
	n = int(input())
	l1 = 0
	l0 = 0
	for j in input().split():
		if j == '1':
			l1 += 1
		else:
			l0 += 1
	line = ''
	if l1 > l0:
		if l1 & 1 == 1:
			for j in range(l1 - 1):
				line += '1 '
		else:
			for j in range(l1):
				line += '1 '
	elif l0 > l1:
		if l1 & 1 == 1:
			for j in range(l0 - 1):
				line += '0 '
		else:
			for j in range(l0):
				line += '0 '
	else:
		for j in range(l0):
			line += '0 '
	otv.append(line)
for i in otv:
	print(len(i) // 2)
	print(i)


test_cases = int(input())
for test_case in range(test_cases):
	n = int(input())
	a = list(map(int, input().split()))
	ones = 0
	zeros = 0
	for i in a:
		if i == 1:
			ones += 1
		else:
			zeros += 1
	if zeros >= ones:
		print(n // 2)
		print('0 ' * (n // 2))
	elif ones % 2 == 0:
		print(ones)
		print('1 ' * ones)
	else:
		print(ones - 1)
		print('1 ' * (ones - 1))


def haha(arr):
	n = len(arr) // 2
	if arr.count(1) <= n:
		blanck = [0] * arr.count(0)
	if arr.count(0) < n:
		c = 0
		if arr.count(1) % 2 != 0:
			c = 1
		blanck = [1] * (arr.count(1) - c)
	print(len(blanck))
	print(*blanck)
	return ''
t = int(input())
for i in range(t):
	a = input()
	lst = list(map(int, input().strip().split()))
	print(haha(lst))


for vishal in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(1) > a.count(0):
		kk = n - a.count(0) - (n - a.count(0)) % 2
		print(kk)
		print(' '.join(['1'] * kk))
	else:
		print(n - a.count(1))
		print(' '.join(['0'] * (n - a.count(1))))


for _ in range(int(input())):
	a = int(input())
	b = [int(x) for x in input().split()]
	(m, n) = (b.count(0), b.count(1))
	if m >= n:
		while 1 in b:
			b.remove(1)
		print(len(b))
		print(*b)
	else:
		if n % 2 == 0:
			while 0 in b:
				b.remove(0)
		else:
			while 0 in b:
				b.remove(0)
			b.remove(1)
		print(len(b))
		print(*b)


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	e = a.count(1)
	o = n - e
	if e - e % 2 >= n // 2:
		b = [1] * (e - e % 2)
	else:
		b = [0] * o
	stdout.write(str(len(b)) + '\n')
	stdout.write(' '.join((str(i) for i in b)) + '\n')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	c1 = ans = 0
	s1 = ''
	a += [100]
	for i in range(n + 1):
		if a[i] == 1:
			c1 += 1
		else:
			if c1 & 1:
				s1 += '1' * (c1 - 1)
				ans += 1
			else:
				s1 += '1' * c1
			if a[i] != 100:
				s1 += '0'
			c1 = 0
	print(n - ans)
	for ch in s1:
		stdout.write(ch + ' ')
	print()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = LI()
	c1 = sum(aa)
	c0 = n - c1
	if c1 > c0:
		k = (n // 2 + 1) // 2 * 2
		ans = [1] * k
		print(k)
		print(*ans)
	else:
		k = n // 2
		ans = [0] * k
		print(k)
		print(*ans)


def input_int():
	return int(input())

def input_int_list():
	return list(map(int, input().split()))

def input_int_map():
	return map(int, input().split())

def run():
	q_num = input_int()
	for i in range(q_num):
		num_count = input_int()
		nums = input_int_list()
		sum_nums = sum(nums)
		result = []
		one_count = sum_nums - sum_nums % 2
		zero_count = num_count - sum_nums
		if one_count >= num_count / 2:
			for i in range(one_count):
				result.append(1)
		else:
			for i in range(zero_count):
				result.append(0)
		print(len(result))
		print(' '.join(map(str, result)))
run()


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
from sys import stdin, stdout
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def printTask(val, n):
	for i in range(n):
		print(val, end=' ')
	print()
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	if ar.count(1) <= ar.count(0):
		print(n // 2)
		printTask(0, n // 2)
	elif n // 2 % 2 == 0:
		print(n // 2)
		printTask(1, n // 2)
	else:
		print(n // 2 + 1)
		printTask(1, n // 2 + 1)
sys.exit(0)
n = int(input())
lis = list(map(int, input().split()))
answer = 0
for i in range(n):
	answer += lis[i] - 1
if n == 1:
	print(n - 1)
elif n > 32:
	print(answer)
	sys.exit(0)
lis.sort()
for i in range(2, 50000):
	localMin = 0
	for j in range(n):
		needVal = i ** j
		localMin += abs(lis[j] - needVal)
		if localMin > answer:
			break
	else:
		answer = min(localMin, answer)
print(answer)
sys.exit(0)

class Person:

	def __init__(self, name, age):
		self.name = name
		self.age = age
p1 = Person('heelo', 27)
print(help(Person))
age = 26
name = 'Swaroop'
print('Возрас {} -- {} лет'.format(name, age))
print(help(object))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = [0, 0]
	for i in arr:
		if i == 1:
			cnt[1] += 1
		else:
			cnt[0] += 1
	rem = n // 2
	if rem % 2 != 0:
		if cnt[0] >= rem:
			print(rem)
			for i in range(rem):
				print(0, end=' ')
			print()
		elif cnt[1] > rem:
			print(rem + 1)
			for i in range(rem + 1):
				print(1, end=' ')
			print()
	elif cnt[1] >= rem:
		print(rem)
		for i in range(rem):
			print(1, end=' ')
		print()
	else:
		print(rem)
		for i in range(rem):
			print(0, end=' ')
		print()


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict, Counter
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

	def inp():
		return int(stdin.readline())

	def minp():
		return map(int, stdin.readline().split())
for _ in range(inp()):
	n = inp()
	a = list(minp())
	odd_sum = 0
	even_sum = 0
	for i in range(1, n + 1):
		if i & 1:
			odd_sum += a[i - 1]
		else:
			even_sum += a[i - 1]
	if odd_sum == even_sum:
		print(n)
		print(*a)
		continue
	count_1 = 0
	count_0 = 0
	for i in range(n):
		if a[i] == 0:
			count_0 += 1
		else:
			count_1 += 1
	if count_0 >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
	elif n // 2 & 1:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print(1, end=' ')
	else:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
	print()


import sys
import math
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ones = sum(a)
	z = n - ones
	if z < n // 2:
		k = n - z
		if k % 2 != 0:
			k -= 1
		print(k)
		for i in range(k):
			print(1, end=' ')
	else:
		print(n - ones)
		for i in range(n - ones):
			print(0, end=' ')
	print()


def ans_f(a):
	if a.count(0) < a.count(1):
		k = a.count(0)
		for j in range(k):
			a.remove(0)
		if a.count(1) % 2 != 0:
			a.remove(1)
	else:
		k = a.count(1)
		for i in range(k):
			a.remove(1)
	return a
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans.append(ans_f(a))
for i in ans:
	print(len(i))
	print(*i)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	o = 0
	z = 0
	for i in range(n):
		if a[i] == 1:
			o += 1
		else:
			z += 1
	if n // 2 % 2 == 0:
		if o <= n // 2:
			print(n - o)
			while 1 in a:
				a.remove(1)
			print(*a)
		elif o % 2 == 0:
			print(o)
			while 0 in a:
				a.remove(0)
			print(*a)
		else:
			print(o - 1)
			while 0 in a:
				a.remove(0)
			a.pop()
			print(*a)
	elif o > z:
		while 0 in a:
			a.remove(0)
		if o % 2 == 1:
			a.pop()
			print(o - 1)
		else:
			print(o)
		print(*a)
	else:
		print(z)
		while 1 in a:
			a.remove(1)
		print(*a)


import sys, math, cmath, time
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	if a.count(1) > a.count(0):
		if a.count(1) % 2 != 0:
			print(a.count(1) - 1)
			print(*[1] * (a.count(1) - 1))
		else:
			print(a.count(1))
			print(*[1] * a.count(1))
	else:
		print(a.count(0))
		print(*[0] * a.count(0))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


import sys
input = sys.stdin.readline
testCases = int(input())
answers = []
for _ in range(testCases):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	if s <= n // 2:
		ans = [0] * (n // 2)
	elif n % 4 == 0:
		ans = [1] * (n // 2)
	else:
		ans = [1] * (n // 2 + 1)
	answers.append(ans)
for ans in answers:
	print(len(ans))
	print(*ans, sep=' ')


def solver(a):
	if sum(a) <= len(a) / 2:
		m = list(filter(lambda x: x == 0, a))
		n = len(m)
	else:
		m = list(filter(lambda x: x == 1, a))
		if len(m) == 1 or len(m) % 2 != 0:
			m = m[:-1]
		n = len(m)
	result = str(n) + '\n' + ' '.join([str(x) for x in m])
	return result
nstr = int(input())
for i in range(nstr):
	N = int(input())
	M = [int(x) for x in input().split()]
	print(solver(M))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	i = 0
	while i + 1 < n:
		if l[i] == l[i + 1]:
			l1.append(l[i])
			l1.append(l[i + 1])
			i += 1
		elif l[i] != l[i + 1]:
			if i + 2 >= n:
				l1.append(0)
				i += 1
				break
			else:
				if l[i + 2] == l[i]:
					l1.append(l[i])
					l1.append(l[i + 2])
				else:
					l1.append(l[i + 1])
					l1.append(l[i + 2])
				i += 2
		i += 1
	print(len(l1))
	print(*l1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	se = so = 0
	for i in range(n):
		if i % 2 == 0:
			se += arr[i]
		else:
			so += arr[i]
	if se == so:
		print(n)
		for a in arr:
			print(a, end=' ')
		print()
	else:
		n1 = n0 = 0
		n1 = se + so
		n0 = n - n1
		if n1 <= n0:
			print(n0)
			for i in range(n0):
				print(0, end=' ')
			print()
		elif n1 % 2 == 0:
			print(n1)
			for i in range(n1):
				print(1, end=' ')
			print()
		else:
			print(n1 - 1)
			for i in range(n1 - 1):
				print(1, end=' ')
			print()


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(int(input())):
		n = int(input())
		a = li()
		if sum(a) > n / 2:
			if n // 2 % 2 == 0:
				print(n // 2)
				print('1 ' * (n // 2))
			else:
				print(n // 2 + 1)
				print('1 ' * (n // 2 + 1))
		else:
			print(n // 2)
			print('0 ' * (n // 2))
solve()


t = int(input())

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	one = 0
	zero = 0
	for i in range(n):
		if a[i] == 1:
			one += 1
		else:
			zero += 1
	if one <= zero:
		print(zero)
		ans = [0 for i in range(zero)]
		print(*ans, sep=' ')
	else:
		if one % 2:
			one -= 1
		print(one)
		ans = [1 for i in range(one)]
		print(*ans, sep=' ')
while t:
	t -= 1
	solve()


for _ in range(int(input())):
	n = int(input())
	al = list(map(int, input().split()))
	ans = []
	one_ok = False
	i = 0
	while i < n:
		if al[i] == 0:
			ans.append(0)
			i += 1
		else:
			ok = False
			for j in range(i + 1, n):
				if al[j] == 1:
					diff = j - i - 1
					ok = True
					break
			if ok:
				ans.append(1)
				if diff % 2 == 0:
					for k in range(diff):
						ans.append(0)
				else:
					for k in range(diff - 1):
						ans.append(0)
				ans.append(1)
			else:
				for j in range(i + 1, n):
					if al[j] == 0:
						ans.append(0)
				break
			i = j + 1
	print(len(ans))
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s1 = 0
	s2 = 0
	for i in range(n):
		if a[i]:
			s1 += 1
		else:
			s2 += 1
	ans = []
	if s1 <= s2:
		ans = [0] * s2
	else:
		ans = [1] * (s1 - s1 % 2)
	print(len(ans))
	if len(ans):
		print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	o = 0
	z = 0
	for i in range(n):
		if l[i]:
			o += 1
		else:
			z += 1
	if o > z:
		o -= o % 2
		print(o)
		for i in range(o):
			print(1, end=' ')
	else:
		print(z)
		for i in range(z):
			print(0, end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	c = a.count(0)
	c1 = a.count(1)
	if c >= n / 2:
		print(c)
		for i in range(c):
			print(0, end=' ')
		print()
	else:
		if c1 & 1:
			c1 -= 1
		print(c1)
		for i in range(c1):
			print(1, end=' ')
		print()
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	n1 = n // 2
	a = [int(i) for i in input().split()]
	s = sum(a)
	if s <= n1:
		print(n1, '0 ' * n1, sep='\n')
	else:
		print(n1 + n1 % 2, '1 ' * (n1 + n1 % 2), sep='\n')


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = get_list()
	if n == 2:
		if ls[0] != ls[1]:
			print(1)
			print(0)
		else:
			print(2)
			print(*ls)
	else:
		(i, ans) = (1, [])
		while i < n:
			if ls[i] == ls[i - 1]:
				ans.extend([ls[i - 1], ls[i]])
				i += 2
			elif i + 1 < n and ls[i] == ls[i + 1]:
				ans.extend([ls[i], ls[i + 1]])
				i += 3
			elif i + 1 < n:
				ans.extend([ls[i - 1], ls[i + 1]])
				i += 3
			else:
				i += 1
		print(len(ans))
		print(*ans)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import re

def _sum(seq):
	if not seq:
		return 0
	else:
		return sum(seq)

def is_ok(numbers):
	return _sum(numbers[::2]) == _sum(numbers[1::2])

def solve_numbers(numbers, idx, initial_len):
	if len(numbers) < initial_len // 2:
		return False
	if is_ok(numbers):
		print(len(numbers))
		print(' '.join(map(str, numbers)))
		return True
	else:
		pass
	if idx == len(numbers):
		return False
	return solve_numbers(numbers[:idx] + numbers[idx + 1:], idx, initial_len) or solve_numbers(numbers, idx + 1, initial_len)

def solve():
	count = int(input())
	for i in range(count):
		_ = input()
		numbers = list(map(int, input().split()))
		solve_numbers(numbers, 0, len(numbers))
solve()


t = int(input())
while t:
	k = f = 0
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		if a[i] == 1:
			k += 1
		else:
			f = f + 1
	if k <= f:
		print(int(n / 2))
		for i in range(int(n / 2)):
			print(0)
	elif n / 2 % 2 == 0:
		print(int(n / 2))
		for i in range(int(n / 2)):
			print(1)
	else:
		print(int(n / 2) + 1)
		for i in range(int(n / 2) + 1):
			print(1)


x = int(input())
ansl = []
for i in range(x):
	y = int(input())
	z = list(map(int, input().split()))
	if z.count(0) < len(z) / 2:
		while z.count(0) > 0:
			z.remove(0)
		if len(z) % 2 == 1 and sum(z) > 0:
			z.remove(1)
	else:
		while z.count(1) > 0:
			z.remove(1)
	rl = [len(z)]
	ansl.append(rl)
	ansl.append(z)
for i in ansl:
	print(*i)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = sum(l)
	if n - o >= n // 2:
		print(n // 2)
		for t in range(n // 2):
			print(0, end=' ')
		print()
	elif o >= n // 2 and n // 2 % 2 == 0:
		print(n // 2)
		for t in range(n // 2):
			print(1, end=' ')
		print()
	else:
		print(n // 2 + 1)
		for t in range(n // 2 + 1):
			print(1, end=' ')
		print()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	sum = list()
	sum.append(a[0])
	for i in range(1, n):
		sum.append(sum[i - 1] + (a[i] if i % 2 == 0 else -a[i]))
	if sum[n - 1] == 0:
		print(n)
		for i in range(n):
			print(a[i], end=' ')
		print()
	else:
		for x in range(n):
			if (sum[x - 1] if x != 0 else 0) + sum[x] - sum[n - 1] == 0:
				print(n - 1)
				for i in range(n):
					if i != x:
						print(a[i], end=' ')
				print()
				return
ct = int(input())
while ct > 0:
	solve()
	ct -= 1


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 5
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	oc = a.count(1)
	zc = a.count(0)
	if oc == zc:
		print(n // 2)
		print(*[0] * zc)
	elif oc > zc:
		if oc % 2 == 1:
			print(oc - 1)
			print(*[1] * (oc - 1))
		else:
			print(oc)
			print(*[1] * oc)
	else:
		print(zc)
		print(*[0] * zc)


test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	ones = a.count(1)
	zeroes = a.count(0)
	if zeroes >= ones:
		print(zeroes)
		print('0 ' * zeroes)
	else:
		if ones % 2 != 0:
			ones -= 1
		print(ones)
		print('1 ' * ones)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	x = arr.count(1)
	if arr.count(0) >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	elif x > n // 2:
		if x % 2 == 0:
			print(x)
			print('1 ' * x)
		else:
			print(x - 1)
			print('1 ' * (x - 1))


import sys

def f(nums):
	res = []
	while nums:
		a = nums.pop(0)
		b = nums.pop(0) if nums else -1
		c = nums.pop(0) if nums else -1
		if a == b:
			res.extend([a, b])
		elif a == c:
			res.extend([a, c])
		elif b == c and c != -1:
			res.extend([b, c])
		elif a != b and c == -1 and (b != -1):
			res.append(0)
	return res
t = int(sys.stdin.readline().strip())
for _ in range(t):
	n = int(sys.stdin.readline().strip())
	nums = list(map(int, sys.stdin.readline().strip().split()))
	out = f(nums)
	sys.stdout.write('%d\n' % len(out))
	for i in range(len(out) - 1):
		sys.stdout.write('%d ' % out[i])
	sys.stdout.write('%d\n' % out[-1])


from sys import stdin

def input():
	return stdin.readline().rstrip()
for _ in range(int(input())):
	l = int(input())
	s = list(map(int, input().split()))
	r = []
	for i in range(l // 2):
		if s[i * 2] == 0 and s[i * 2 + 1] == 0:
			r.append(0)
			r.append(0)
		elif s[i * 2] == 1 and s[i * 2 + 1] == 1:
			r.append(1)
			r.append(1)
		else:
			r.append(0)
	print(len(r))
	print(*r)


for i in range(int(input())):
	n = int(input())
	arr = list(input().split())
	arr.sort(reverse=True)
	if '0' in arr:
		idx = arr.index('0')
		if arr.count('0') >= arr.count('1'):
			arr = arr[idx:]
		else:
			arr = arr[:idx]
			if len(arr) % 2 != 0:
				arr.pop()
	elif len(arr) % 2 != 0:
		arr.pop()
	print(len(arr))
	print(*arr)


class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		n = Read.int()
		a = Read.list_int()
		b = list()
		i = 0
		while n > i:
			if i == n - 1:
				if a[i] == 0:
					b.append(a[i])
				break
			if a[i] == a[i + 1]:
				b.append(a[i])
				b.append(a[i + 1])
				i += 2
			elif i == n - 2:
				if a[i] == 0 or a[i + 1] == 0:
					b.append(0)
				break
			elif a[i + 2] == a[i + 1]:
				b.append(a[i + 1])
				b.append(a[i + 2])
				i += 3
			else:
				b.append(a[i])
				b.append(a[i + 2])
				i += 3
		print(len(b))
		print(*b)
main()


for _ in range(int(input())):
	size = int(input())
	l = list(map(int, input().split()))
	zeros = l.count(0)
	if zeros >= size // 2:
		ans = '0' * zeros
	else:
		ones = l.count(1)
		ones //= 2
		ones *= 2
		ans = '1' * ones
	print(len(ans))
	ans = list(ans)
	ans = ' '.join(ans)
	print(ans)


T = int(input())
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	one_count = 0
	for i in A:
		if i == 1:
			one_count += 1
	if one_count <= n // 2:
		ans = [0] * (n - one_count)
	elif one_count % 2:
		ans = [1] * (one_count - 1)
	else:
		ans = [1] * one_count
	print(len(ans))
	print(*ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	one = a.count(1)
	zero = a.count(0)
	if one % 2 == 0:
		if one >= n // 2:
			res = [a[i] for i in range(n) if a[i] == 1]
			print(len(res))
			print(*res)
		else:
			res = [a[i] for i in range(n) if a[i] == 0]
			print(len(res))
			print(*res)
	elif one <= n // 2:
		res = [a[i] for i in range(n) if a[i] == 0]
		print(len(res))
		print(*res)
	else:
		res = []
		flag = False
		for i in range(n):
			if a[i] == 1:
				if not flag:
					flag = True
					continue
				else:
					res.append(a[i])
		print(len(res))
		print(*res)


tests = int(input())
for t in range(tests):
	n = int(input())
	ls = list(map(int, input().split()))
	res = []
	curr = 0
	for item in ls:
		if item == 0:
			if curr % 2 == 1:
				res[-1] = 0
			else:
				res.append(item)
			curr = 0
		else:
			res.append(item)
			curr += 1
	if curr % 2 == 1:
		res = res[:-1]
	print(len(res))
	print(' '.join(list(map(str, res))))


for i in range(int(input())):
	n = int(input()) // 2
	arr = input()
	x = '1 ' if arr.count('1') > arr.count('0') else '0 '
	if x == '1 ' and n % 2 == 1:
		n += 1
	print(n, x * n, sep='\n')


import sys
import os.path
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
	sys.stdout = open('out.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	s = ''.join(map(str, li))
	if n - li.count(1) >= n // 2:
		ans = '0' * (n - li.count(1))
	else:
		ans = '1' * li.count(1)
		if len(ans) % 2:
			ans = ans[:len(ans) - 1]
	print(len(ans))
	print(' '.join(ans))


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	a = inl()
	ans = []
	for i in range(0, n, 2):
		if a[i] == a[i + 1]:
			ans.append(a[i])
			ans.append(a[i + 1])
		else:
			ans.append(0)
	print(len(ans))
	print(*ans)


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	if a.count(0) >= n // 2:
		print(n // 2)
		print(' '.join(['0'] * (n // 2)))
	else:
		print(n // 2 + n // 2 % 2)
		print(' '.join(['1'] * (n // 2 + n // 2 % 2)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	z = o = 0
	for i in a:
		if i == 1:
			o += 1
		else:
			z += 1
	if z >= o:
		print(z)
		ans = [0] * z
		print(*ans)
	else:
		if o % 2 != 0:
			o -= 1
		ans = []
		for i in range(o):
			ans.append(1)
		print(len(ans))
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ca = a.count(1)
	cb = n - ca
	if cb >= (n + 1) // 2:
		print(cb)
		print('0 ' * cb)
	elif ca % 2 == 0:
		print(ca)
		print('1 ' * ca)
	else:
		print(ca - 1)
		print('1 ' * (ca - 1))


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	nb0 = len([el for el in A if el == 0])
	if nb0 >= N // 2:
		print(N // 2)
		print(' '.join(map(str, [0] * (N // 2))))
		continue
	if N // 2 % 2 == 0:
		print(N // 2)
		print(' '.join(map(str, [1] * (N // 2))))
		continue
	print(N // 2 + 1)
	print(' '.join(map(str, [1] * (N // 2 + 1))))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ones = 0
	zeros = 0
	for i in range(n):
		if a[i] == 0:
			zeros += 1
		else:
			ones += 1
	if ones > n // 2:
		if ones % 2 == 1:
			ones -= 1
		print(ones)
		for i in range(ones):
			print(1, end=' ')
		print()
	else:
		print(zeros)
		for i in range(zeros):
			print(0, end=' ')
		print()


for s in [*open(0)][2::2]:
	a = (*map(len, s[::2].split('0')),)
	r = '0'.join(('1' * (x - x % 2) for x in a))
	print(len(r), *r)


ans_amount = []
ans_str = []
tests = int(input())
for i in range(tests):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	zero_ctr = 0
	one_ctr = 0
	for j in range(n):
		if a[j] == 0:
			zero_ctr += 1
		else:
			one_ctr += 1
	if one_ctr <= zero_ctr:
		ans_amount.append(zero_ctr)
		ans_str.append('0 ' * zero_ctr)
	else:
		ans_amount.append(int(one_ctr / 2) * 2)
		ans_str.append('1 ' * int(one_ctr / 2) * 2)
for i in range(len(ans_amount)):
	print(ans_amount[i])
	print(ans_str[i])


def ahahahaha(str_size, s):
	if str_size == 1:
		return ['0']
	elif str_size == 2:
		if '0' in s:
			return ['0']
		else:
			return ['1', '1']
	else:
		result = []
		rem = str_size % 3
		start = 0
		if rem == 1:
			start = 1
		elif rem == 2:
			if '0' in s[0:2]:
				result += ['0']
			else:
				result += ['1', '1']
			start = 2
		for i in range(start, str_size, 3):
			subs = s[i:i + 3]
			occ_0 = 0
			occ_1 = 0
			for i in subs:
				if i == '0':
					occ_0 += 1
				else:
					occ_1 += 1
			if occ_0 >= 2:
				result += ['0', '0']
			elif occ_1 >= 2:
				result += ['1', '1']
		return result
t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	result = ahahahaha(n, s)
	print(len(result))
	print(' '.join(result))


from math import log2, ceil

def readGenerator():
	while True:
		tokens = input().split(' ')
		for t in tokens:
			yield t
reader = readGenerator()

def readWord():
	return next(reader)

def readInt():
	return int(next(reader))

def readFloat():
	return float(next(reader))

def readLine():
	return input()

def solve(a):
	(v0, v1) = (0, 0)
	for i in a:
		if i == 0:
			v0 += 1
		else:
			v1 += 1
	if v1 > v0:
		if v1 % 2 != 0:
			v1 -= 1
		print(v1)
		return '1 ' * v1
	print(v0)
	return '0 ' * v0
tests = readInt()
for i in range(tests):
	n = readInt()
	a = [readInt() for _ in range(n)]
	print(solve(a))


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	(d[0], d[1]) = (0, 0)
	for i in range(n):
		d[arr[i]] += 1
	if d[0] >= d[1]:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	elif n // 2 % 2 == 1:
		isPrinted = False
		count = 0
		ans = []
		val = n // 2
		for i in range(n):
			if arr[i] == 0:
				if isPrinted == False:
					if count % 2 == 0:
						ans.append(arr[i])
						isPrinted = True
						count += 1
					else:
						ans[-1] = 0
						isPrinted = True
			elif count < val:
				if isPrinted == False:
					if count < val - 1:
						ans.append(1)
						count += 1
				else:
					ans.append(1)
					count += 1
			else:
				break
		if isPrinted == False:
			ans.append(1)
			ans.append(1)
		print(len(ans))
		for i in range(len(ans)):
			print(ans[i], end=' ')
		print()
	else:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
		print()


def ans(a, n):
	ones = 0
	zeroes = 0
	for i in a:
		if i == 0:
			zeroes += 1
		else:
			ones += 1
	if zeroes > ones:
		print(zeroes)
		s = '0 ' * zeroes
		print(s)
	elif zeroes < ones:
		if ones % 2 == 0:
			print(ones)
			s = '1 ' * ones
			print(s)
		else:
			print(ones - 1)
			s = '1 ' * (ones - 1)
			print(s)
	else:
		print(zeroes)
		s = '0 ' * zeroes
		print(s)
	return
m = int(input())
for i in range(m):
	n = int(input())
	arr = input().split()
	a = []
	for i in arr:
		a.append(int(i))
	ans(a, n)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = l.count(1)
	z = l.count(0)
	ans = []
	if o <= n // 2:
		ans = [0] * z
	else:
		ans = [1] * o
	if len(ans) % 2 != 0 and ans[0] == 1:
		ans.pop()
	print(len(ans))
	print(*ans)


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	m = l.count(1)
	if m > int(a / 2):
		i = 0
		while i < len(l):
			if not l[i]:
				l.pop(i)
				i -= 1
			i += 1
		if m % 2 == 1:
			l.remove(1)
	else:
		i = 0
		while i < len(l):
			if l[i]:
				l.pop(i)
				i -= 1
			i += 1
	print(len(l))
	for i in range(len(l) - 1):
		print(l[i], end=' ')
	print(l[len(l) - 1])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	odd_sum = 0
	even_sum = 0
	for i in range(n):
		if i % 2 == 0:
			odd_sum += arr[i]
		else:
			even_sum += arr[i]
	diff = max(odd_sum, even_sum) - min(even_sum, odd_sum)
	for i in range(len(arr)):
		curr_oddsum = 0
		curr_evensum = 0
		flag = 0
		for j in range(0, i):
			if arr[j] != -1:
				if flag == 0:
					flag = 1
					curr_oddsum += arr[j]
				else:
					flag = 0
					curr_evensum += arr[j]
		for j in range(i + 1, len(arr)):
			if arr[j] != -1:
				if flag == 0:
					flag = 1
					curr_oddsum += arr[j]
				else:
					flag = 0
					curr_evensum += arr[j]
		d = max(curr_oddsum, curr_evensum) - min(curr_evensum, curr_oddsum)
		if d < diff:
			diff = d
			arr[i] = -1
	ans = ''
	ans_len = 0
	for i in range(n):
		if arr[i] != -1:
			ans += str(arr[i]) + ' '
			ans_len += 1
	print(ans_len)
	print(ans)


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

def solve(t, A):
	zeros = A.count(0)
	ones = A.count(1)
	half = t // 2
	if zeros > half:
		return ['0'] * (zeros // 2 * 2)
	elif ones > half:
		return ['1'] * (ones // 2 * 2)
	elif half % 2 == 0:
		return ['1'] * half
	elif A[0] == 0:
		return ['0'] + ['1'] * (half - 1)
	elif A[-1] == 0:
		return ['1'] * (half - 1) + ['0']
	else:
		return ['1'] + ['0'] * (half - 1) + ['1']

def main():
	n = int(input())
	ans = []
	for _ in range(n):
		t = int(input())
		ans.append(solve(t, list(map(int, input().split(' ')))))
	for r in ans:
		print(len(r))
		print(' '.join(r))
main()


for _ in range(int(input())):
	n = int(input())
	arr = [int(j) for j in input().split()]
	c1 = arr.count(1)
	c2 = arr.count(0)
	if c2 > c1:
		x = [0] * c2
		print(c2)
		print(*x)
	elif c1 % 2 == 0:
		x = [1] * c1
		print(c1)
		print(*x)
	elif c2 < n / 2:
		x = [1] * (c1 - 1)
		print(c1 - 1)
		print(*x)
	elif c2 == n / 2:
		x = [0] * c2
		print(c1)
		print(*x)


def works(l):
	x = 0
	for i in range(len(l)):
		if i % 2:
			x += int(l[i])
		else:
			x -= int(l[i])
	return x == 0
for _ in range(int(input())):
	n = int(input())
	l = input().split()
	if works(l):
		print(n)
		print(' '.join(l))
	else:
		for i in range(n):
			t = list(l)
			x = t.pop(i)
			if works(t):
				print(len(t))
				print(' '.join(t))
				break


def func2(arr, n):
	count = [0, 0]
	for e in arr:
		count[e] += 1
	if count[0] >= n / 2:
		print(n // 2)
		for i in range(0, n // 2):
			print('0', end=' ')
		print()
	else:
		x = n // 2
		if x % 2 == 0:
			print(x)
			for e in range(0, n // 2):
				print('1', end=' ')
			print()
		else:
			print(x + 1)
			for e in range(0, n // 2 + 1):
				print('1', end=' ')
			print()
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	func2(arr, n)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	c1 = a.count(1)
	c0 = a.count(0)
	if n == 2:
		if c1 == 1:
			print(1)
			return [0]
		if c1 == 0:
			print(2)
			return [0, 0]
		if c1 == 2:
			print(2)
			return [1, 1]
	if c1 == c0:
		print(c1)
		return [0] * c1
	elif c1 > c0:
		if c1 % 2 == 0:
			print(c1)
			return [1] * c1
		else:
			print(c1 - 1)
			return [1] * (c1 - 1)
	elif c0 % 2 == 0:
		print(c0)
		return [0] * c0
	else:
		print(c0 - 1)
		return [0] * (c0 - 1)
T = int(input())
for i in range(T):
	a = solve()
	n = len(a)
	for i in range(n):
		if i == n - 1:
			print(a[i])
		else:
			print(a[i], end=' ')


from collections import Counter, deque
import math
from random import randint
from bisect import bisect
import sys
import re
import copy
MOD = 1000000007
MAX = sys.maxsize
MIN = -sys.maxsize

class get:

	def int():
		return list(map(int, input().split()))

	def str():
		return input().split()

	def float():
		return list(map(float, input().split()))

	def map():
		return map(int, input().split())

def sqrt(x):
	return int(math.sqrt(x)) + 1

def gcd(*args):
	result = args[0]
	for item in args:
		result = math.gcd(result, item)
	return result

def LCM(a, b):
	return a * b // math.gcd(a, b)

def solve():
	n = int(input())
	arr = get.int()
	c_0 = arr.count(0)
	c_1 = arr.count(1)
	if c_0 > c_1:
		res = [0] * (c_0 // 2 * 2)
		print(len(res))
		print(*res)
	elif c_1 > c_0:
		res = [1] * (c_1 // 2 * 2)
		print(len(res))
		print(*res)
	else:
		print(n // 2)
		res = [0] * (n // 2)
		print(*res)
for _ in range(int(input())):
	solve()


t = int(input())
answer = []
for _ in range(t):
	n = int(input())
	liste = list(map(int, input().split(' ')))
	sum_list = sum([liste[i] * (-1) ** i for i in range(len(liste))])
	tmp = list(map(str, liste))
	count = len(liste)
	if sum_list != 0:
		if liste.count(0) >= n / 2:
			count = liste.count(0)
			tmp = [str(0) for i in range(count)]
		else:
			count = liste.count(1)
			if count % 2 != 0:
				count -= 1
			tmp = [str(1) for i in range(count)]
	answer.append(str(count))
	answer.append(' '.join(tmp))
print('\n'.join(answer))


cases = int(input())
for i in range(cases):
	n = int(input())
	l2 = input().split(' ')
	arr = []
	for a in l2:
		arr.append(int(a))
	count = 0
	for j in range(n):
		n = arr[j]
		if n == 1:
			count += 1
		if n == 0:
			if count % 2 == 0:
				continue
			else:
				arr[j - 1] = -1
				count = 0
	if count % 2 == 1:
		arr[-1] = -1
	sol = []
	for a in arr:
		if a != -1:
			sol.append(str(a))
	print(len(sol))
	print(' '.join(sol))


for _ in range(int(input())):
	a = int(input()) // 2
	b = input().split()
	if b.count('0') < b.count('1'):
		c = '1 '
		if a % 2 == 1:
			a += 1
	else:
		c = '0 '
	print(a)
	print(a * c)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	cnt0 = a.count(0)
	if cnt0 >= n // 2:
		a = [i for i in a if i == 0]
	else:
		a = [i for i in a if i == 1]
		if len(a) % 2 == 1:
			a.pop()
	print(len(a))
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = [1] * (n // 2)
	y = [0] * (n // 2)
	if a.count(0) >= n // 2:
		print(n // 2)
		print(*y)
	elif n // 2 % 2 == 0:
		print(n // 2)
		print(*x)
	else:
		print(n // 2 + 1)
		print(*[1] * (n // 2 + 1))


t = int(input())
for tests in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	zeros_count = a.count(0)
	ones_count = n - zeros_count
	if ones_count % 2 != 0 and n > 2:
		a.remove(1)
		ones_count -= 1
	if zeros_count >= ones_count:
		k = zeros_count
		output = [0] * k
	else:
		k = ones_count
		output = [1] * k
	print(k)
	print(*output)


import os
import sys
from io import BytesIO, IOBase
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	z = 0
	o = 0
	for i in range(n):
		if l[i] == 1:
			o += 1
		else:
			z += 1
	if o <= n // 2:
		print(z)
		for i in range(z):
			print(0, end=' ')
		print()
	else:
		print(n // 2 + n // 2 % 2)
		for i in range(n // 2 + n // 2 % 2):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	A = [int(i) for i in input().split()]
	(ones, zeroes) = (A.count(1), A.count(0))
	if ones > zeroes:
		final = '1' * ones
		if len(final) % 2:
			ones -= 1
			final = '1' * ones
		print(ones)
	else:
		final = '0' * zeroes
		print(zeroes)
	print(' '.join(final))


from collections import deque
import copy
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	z = l.count(0)
	o = l.count(1)
	if z >= n // 2:
		print(z)
		print('0 ' * z)
	elif o >= n // 2:
		print(o // 2 * 2)
		print('1 ' * (o // 2 * 2))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	one = 0
	zero = 0
	for i in range(n):
		if arr[i] == 0:
			zero += 1
		else:
			one += 1
	if zero == 0 or one == 0:
		print(n)
		print(*arr)
	elif zero > one:
		ar = [0] * (zero // 2 * 2)
		print(len(ar))
		print(*ar)
	elif one > zero:
		ar = [1] * (one // 2 * 2)
		print(len(ar))
		print(*ar)
	elif zero % 2 == 0:
		ar = [0] * zero
		print(zero)
		print(*ar)
	elif zero == 1:
		print(1)
		print(0)
	else:
		ar = []
		x = 0
		while x < n - 2:
			if arr[x] == arr[x + 1]:
				ar.append(arr[x])
				ar.append(arr[x + 1])
				x += 2
			elif arr[x] == arr[x + 2]:
				ar.append(arr[x])
				ar.append(arr[x + 2])
				x += 3
			else:
				ar.append(arr[x + 1])
				ar.append(arr[x + 2])
				x += 3
		print(len(ar))
		print(*ar)


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	(zero, one) = (0, 0)
	if n % 4 == 0:
		for i in range(n):
			if a[i] == 0:
				zero += 1
			else:
				one += 1
		print(n // 2)
		if zero >= n // 2:
			for i in range(n // 2):
				print(0, end=' ')
		elif one >= n // 2:
			for i in range(n // 2):
				print(1, end=' ')
	else:
		for i in range(n):
			if a[i] == 0:
				zero += 1
			else:
				one += 1
		if one >= n // 2 + 1:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ')
		elif zero >= n // 2 + 1:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(0, end=' ')
		elif one == zero:
			print(n // 2)
			for i in range(n // 2):
				print(0, end=' ')
	print()


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	res = []
	l = 0
	r = 1
	while r < n:
		if s[l] == s[r]:
			res.append(s[l])
			res.append(s[r])
			l = r + 1
			r = l + 1
		elif r + 1 < n:
			res.append(s[r + 1])
			res.append(s[r + 1])
			l = r + 2
			r = l + 1
		else:
			r += 1
	x = len(res)
	if x == 0:
		print('1\n0')
	else:
		print(x)
		print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	q = 0
	a = [int(i) for i in input().split()]
	for i in range(len(a)):
		if a[i] == 0:
			q += 1
	q1 = n - q
	if q >= n / 2:
		print(q)
		for i in range(q):
			print(0)
	else:
		print(q1 - q1 % 2)
		for i in range(q1 - q1 % 2):
			print(1)


t = int(input())
while t > 0:
	n = int(input())
	x = [int(x) for x in input().split()]
	x0 = x[0::2]
	x1 = x[1::2]
	if len(x) % 2 != 0:
		x.remove(x[int((n + 1) / 2 - 1)])
		count = 1
	else:
		count = 0
	arr = []
	for i in range(len(x1)):
		if x0[i] == x1[i]:
			arr.append(x0[i])
			arr.append(x1[i])
		elif x0[i] == 0:
			count += 1
			arr.append(x0[i])
		else:
			count += 1
			arr.append(x1[i])
	print(n - count)
	for item in arr:
		print(item, end=' ')
	print('')
	t -= 1


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	zer = 0
	one = 0
	for s in range(n):
		if vals[s] == 0:
			zer += 1
		else:
			one += 1
	if zer == 0:
		print(n)
		print(*vals)
	elif one == 0:
		print(n)
		print(*vals)
	elif zer == one:
		print(n - one)
		print(*[0 for s in range(n - one)])
	elif zer < one:
		if zer % 2 == 0:
			print(n - zer)
			print(*[1 for s in range(n - zer)])
		else:
			print(n - (zer + 1))
			ans = [1 for s in range(n - (zer + 1))]
			print(*ans)
	else:
		print(n - one)
		print(*[0 for s in range(n - one)])


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '4\n2\n1 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(a):
	zeroes = len([x for x in a if x == 0])
	ones = len([x for x in a if x == 1])
	if zeroes >= len(a) / 2:
		return [0] * zeroes
	if ones % 2:
		ones -= 1
	return [1] * ones
t = getType(int)
for _ in range(t):
	n = getType(int)
	a = getArray(int)
	arr = solve(a)
	print(len(arr))
	print(' '.join(list(map(str, arr))))


def main():
	n = int(input())
	lst = list(map(int, input().split()))
	zero = 0
	for i in lst:
		if i == 0:
			zero += 1
	if zero >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	else:
		print(n // 2 + n // 2 % 2)
		print('1 ' * (n // 2 + n // 2 % 2))
t = int(input())
for i in range(t):
	main()


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			high = mid
		else:
			low = mid + 1
	return low

def check(size, w, h, n):
	return size // w * (size // h) >= n
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis

def solve():
	n = int(input())
	a = list(read())
	if a.count(1) > n // 2:
		if n // 2 % 2 == 0:
			print(n // 2)
			print(*[1] * (n // 2))
		else:
			print(n // 2 + 1)
			print(*[1] * (n // 2 + 1))
	elif a.count(0) > n // 2:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		print(n // 2)
		print(*[0] * (n // 2))
for _ in range(int(input())):
	solve()


t = int(input())
while t:
	t -= 1
	n = int(input())
	A = [int(j) for j in input().split()]
	even = 0
	odd = 0
	for i in range(n):
		if i % 2 == 0:
			even += A[i]
		else:
			odd += A[i]
	if even == odd:
		print(n)
		print(*A)
	else:
		one = A.count(1)
		zero = A.count(0)
		if one > zero:
			if n // 2 % 2 == 0:
				print(n // 2)
				for i in range(n // 2):
					print('1', end=' ')
				print()
			else:
				print(n // 2 + 1)
				for i in range(n // 2 + 1):
					print('1', end=' ')
				print()
		else:
			print(n // 2)
			for i in range(n // 2):
				print('0', end=' ')
			print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	no_zeros = 0
	for i in range(n):
		if a[i] == 0:
			no_zeros += 1
	if no_zeros >= n / 2:
		print(no_zeros)
		for i in range(no_zeros):
			print(0, end=' ')
	else:
		x = n - no_zeros
		z = x if x % 2 == 0 else x - 1
		print(z)
		for i in range(z):
			print(1, end=' ')
	print()


for q in range(int(input())):
	n = int(input())
	a = input().split()
	one = a.count('1')
	z = n - one
	if one <= n // 2:
		print(z)
		print('0 ' * z)
	elif one % 2 == 0:
		print(one)
		print('1 ' * one)
	else:
		print(one - 1)
		print('1 ' * (one - 1))


t = int(input())
for sdfhyujkl in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(0, n, 2):
		if l[i] != l[i + 1]:
			l[i] = -l[i]
			l[i + 1] = -l[i + 1]
	answer = []
	for i in range(n):
		if l[i] != -1:
			answer.append(l[i])
	print(len(answer))
	print(*answer)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	no = a.count(1)
	if no == n or no == 0:
		print(n)
		print(*a)
	elif no <= n // 2:
		print(n - no)
		print('0 ' * (n - no))
	elif no % 2 == 0:
		print(no)
		print('1 ' * no)
	else:
		no -= 1
		print(no)
		print('1 ' * no)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(x) for x in input().split()]
	if l1.count(1) > l1.count(0):
		print(n // 2 + n // 2 % 2)
		print(*[1] * (n // 2 + n // 2 % 2))
	else:
		print(n // 2)
		print(*[0] * (n // 2))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	w = input()[:-1].replace(' ', '')
	s = ''
	if n == 2:
		if w != '11':
			print(1)
			print(0)
		else:
			print(2)
			print(1, 1)
	else:
		if n % 3 == 1:
			w = w[:-1]
		elif n % 3 == 2:
			w = w[:-2]
		for i in range(0, n, 3):
			if w[i:i + 3] == '111':
				s += '11'
			elif w[i:i + 3] == '110':
				s += '11'
			elif w[i:i + 3] == '101':
				s += '11'
			elif w[i:i + 3] == '011':
				s += '11'
			elif w[i:i + 3] == '000':
				s += '00'
			elif w[i:i + 3] == '001':
				s += '00'
			elif w[i:i + 3] == '010':
				s += '00'
			elif w[i:i + 3] == '100':
				s += '00'
		print(len(s))
		print(s.replace('', ' ').strip())


t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	if n == 2:
		if l == [1, 1]:
			print(2)
			print(1, 1)
		else:
			print(1)
			print(0)
	else:
		i = 0
		ans = []
		while 1:
			if len(ans) >= n // 2:
				break
			if l[i] == l[i + 1]:
				ans.append(l[i])
				ans.append(l[i + 1])
				i += 2
			else:
				if l[i] == l[i + 2]:
					ans.append(l[i])
					ans.append(l[i + 2])
				else:
					ans.append(l[i + 1])
					ans.append(l[i + 2])
				i += 3
		print(len(ans))
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = n - o
	if z >= n // 2:
		print(n // 2)
		f = [0] * (n // 2)
		print(*f)
	elif o & 1:
		print(n - z - 1)
		f = [1] * (n - z - 1)
		print(*f)
	else:
		print(n - z)
		f = [1] * (n - z)
		print(*f)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	k = sum(a)
	s = []
	if k > n - k:
		for i in a:
			if i == 1:
				s.append(i)
		if len(s) % 2 != 0:
			s.remove(1)
	else:
		for i in a:
			if i == 0:
				s.append(i)
	print(len(s))
	print(*s, sep=' ')


from math import gcd, ceil, log
from collections import Counter, deque

def rl():
	return list(map(int, input().split()))

def arp(arr):
	return ' '.join([str(i) for i in arr])
for _ in range(int(input())):
	(n,) = rl()
	arr = rl()
	(o, z) = (0, 0)
	for i in arr:
		if i == 1:
			o += 1
		else:
			z += 1
	if n == 2 and arr[0] == 1 and (arr[1] == 1):
		print(n)
		print(arp(arr))
	else:
		anss = []
		zzzz = []
		if o <= n // 2:
			for i in range(z):
				zzzz.append(0)
			print(n - o)
			print(arp(zzzz))
		else:
			if o & 1:
				o -= 1
			for i in range(o):
				anss.append(1)
			print(len(anss))
			print(arp(anss))


a = int(input())
i = 1
while i < a + 1:
	b = int(input())
	c = input()
	if c.count('0') >= b / 2:
		print(b // 2)
		print('0 ' * int(b / 2))
	elif b / 2 % 2 == 0:
		print(b // 2)
		print('1 ' * int(b / 2))
	else:
		print(b // 2 + 1)
		print('1 ' * int(b / 2 + 1))
	i += 1


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c_1 = arr.count(1)
	c_0 = arr.count(0)
	if c_0 >= n // 2:
		print(c_0)
		print(' '.join(('0' for i in range(c_0))))
	else:
		if c_1 % 2 != 0:
			c_1 -= 1
		print(c_1)
		print(' '.join(('1' for i in range(c_1))))


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):
	zeroes = A.count(0)
	ones = A.count(1)
	assert zeroes + ones == N
	if zeroes >= N // 2:
		A = [0] * zeroes
	else:
		A = [1] * (2 * (ones // 2))
	return str(len(A)) + '\n' + ' '.join(map(str, A))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	i = 0
	ans = [1] * n
	while i < n:
		if i < n - 1 and A[i] == A[i + 1]:
			i += 1
		elif A[i]:
			ans[i] = 0
		i += 1
	print(sum(ans))
	print(*[A[i] for i in range(n) if ans[i]])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	z = a.count(0)
	o = n - z
	if z >= n // 2:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		x = n // 2
		if x % 2 == 1:
			x += 1
		print(x)
		print(*[1] * x)


import sys

def answer(n, a):
	if a.count(1) <= n // 2:
		print(n - a.count(1))
		print('0 ' * a.count(0))
		return
	if a.count(1) % 2 == 0:
		print(a.count(1))
		print('1 ' * a.count(1))
		return
	print(a.count(1) - 1)
	print('1 ' * (a.count(1) - 1))
	return

def main():
	t = int(input())
	while t:
		n = int(input())
		a = [int(i) for i in sys.stdin.readline().split()]
		answer(n, a)
		t -= 1
	return
main()


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	if a.count(1) <= a.count(0):
		a2 = [int(x) for x in a if x == 0]
		print(len(a2))
		print(*a2)
	else:
		a2 = [int(x) for x in a if x == 1]
		if len(a2) % 2 == 1:
			a2.pop()
		print(len(a2))
		print(*a2)


t = int(input())
while t > 0:
	n = int(input())
	li = list(map(int, input().split()))
	s = sum(li)
	if s == n or s == 0:
		print(n)
		for item in li:
			print(item, end=' ')
			pass
		print()
	elif s <= n / 2:
		print(n - s)
		i = 0
		while i < s:
			li.remove(1)
			i += 1
			pass
		for item in li:
			print(item, end=' ')
			pass
		print()
	elif s > n / 2:
		i = 0
		while i < n - s:
			li.remove(0)
			i += 1
			pass
		if s % 2 == 0:
			print(s)
			for item in li:
				print(item, end=' ')
			print()
		else:
			del li[0]
			print(s - 1)
			for item in li:
				print(item, end=' ')
			print()
		pass
	t -= 1
	pass


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		n = Int()
		a = List()
		o = a.count(1)
		z = a.count(0)
		if z >= o:
			ans = '0' * z
		else:
			ans = '1' * (o - o % 2)
		print(len(ans))
		print(' '.join(ans))
solution()


for _ in range(int(input())):
	n = int(input())
	A = [int(_) for _ in input().split()]
	(zrs, one) = (0, 0)
	for _ in range(n):
		if A[_] == 1:
			one += 1
		else:
			zrs += 1
	if zrs >= one or one == 1:
		print(zrs)
		for _ in range(zrs):
			print(0, end=' ')
		print()
	else:
		if one % 2 == 1:
			one -= 1
		print(one)
		for _ in range(one):
			print(1, end=' ')
		print()


import math
from decimal import *
import random
for _ in range(int(input())):
	n = int(input())
	arr = list(map(str, input().split()))
	(ones, zeroes) = (0, 0)
	for i in range(n):
		if arr[i] == '1':
			ones += 1
		else:
			zeroes += 1
	if zeroes >= n // 2:
		print(zeroes)
		print('0 ' * zeroes)
	else:
		print(ones // 2 * 2)
		print('1 ' * (ones // 2 * 2))


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	ct0 = 0
	ct1 = 0
	for c in a:
		if c == '0':
			ct0 += 1
		else:
			ct1 += 1
	if ct0 >= ct1:
		key = '0'
		ct = ct0
	else:
		key = '1'
		ct = ct1
		ct = ct - ct % 2
	output = [key] * ct
	output = ' '.join(output)
	print(ct)
	print(output)


import io
import os
import sys
import math
fileno = sys.stdin.fileno()
input = io.BytesIO(os.read(fileno, os.fstat(fileno).st_size)).readline
T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ones = sum(A)
	if ones <= N // 2:
		k = N - ones
		print(k)
		print(' '.join(('0' for i in range(k))))
	else:
		k = ones - ones % 2
		print(k)
		print(' '.join(('1' for i in range(k))))


import sys
ll = lambda : list(map(int, input().split()))
lls = lambda : list(map(str, input().split()))
fin = lambda : list(map(float, input().split()))
st = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
mod = 10 ** 9 + 7
from math import *
from datetime import datetime
from collections import *
import math

def Sum(n):
	sum = 0
	while n > 0:
		sum += int(n % 10)
		n = int(n / 10)
	return sum
for _ in range(ii()):
	n = ii()
	l = ll()
	i = 0
	while i < len(l) - 1:
		if l[i] != l[i + 1]:
			if i + 2 >= len(l):
				l = l[:len(l) - 2] + [0]
			elif l[i] == l[i + 2]:
				l = l[:i + 1] + l[i + 2:]
			else:
				l = l[:i] + l[i + 1:]
		i += 2
	if len(l) % 2 and l[-1] == 1:
		l = l[:len(l) - 1]
	print(len(l))
	print(*l)


testcases = int(input())
for _ in range(testcases):
	n = int(input())
	l = list(map(int, input().split()))
	cnt0 = l.count(0)
	cnt1 = n - cnt0
	if cnt0 >= n // 2:
		print(cnt0)
		for i in range(cnt0 - 1):
			print(0, end=' ')
		else:
			print(0)
	else:
		print(cnt1 - cnt1 % 2)
		for i in range(cnt1 - cnt1 % 2 - 1):
			print(1, end=' ')
		else:
			print(1)


def run():
	n = int(input())
	nums = list(map(int, input().split()))
	num1 = nums.count(0)
	if num1 >= n // 2:
		print(n // 2)
		print(' '.join(('0' for i in range(n // 2))))
	elif n // 2 & 1:
		print(n // 2 + 1)
		print(' '.join(('1' for i in range(n // 2 + 1))))
	else:
		print(n // 2)
		print(' '.join(('1' for i in range(n // 2))))
T = 1
if T:
	for i in range(int(input())):
		run()
else:
	run()


t = int(input())
for i in range(t):
	n = int(input())
	arr = input().split(' ')
	count = 0
	for i in range(n - 1, -1, -1):
		if arr[i] == '1':
			count += 1
		else:
			if count % 2 != 0:
				arr.pop(i + 1)
			count = 0
	if count % 2 != 0:
		arr.pop(0)
	print(len(arr))
	print(' '.join(arr))


tc = int(input())
for _ in range(tc):
	n = int(input())
	a = [x for x in input().strip().split()]
	o = a.count('1')
	z = a.count('0')
	if o > z:
		if n // 2 % 2 == 0:
			print(n // 2)
			print('1 ' * (n // 2))
		else:
			print(n // 2 + 1)
			print('1 ' * (n // 2 + 1))
	elif z > o:
		print(n // 2)
		print('0 ' * (n // 2))
	else:
		print(n // 2)
		print('0 ' * (n // 2))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	cnt = 0
	for i in range(len(l)):
		if l[i] == 0:
			c += 1
		else:
			cnt += 1
	if c >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print('0', end=' ')
	elif cnt > n // 2:
		if cnt % 2 == 0:
			print(cnt)
			for i in range(cnt):
				print('1', end=' ')
		else:
			print(cnt - 1)
			for i in range(cnt - 1):
				print('1', end=' ')
	print()


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	odd = 0
	even = 0
	for i in range(n):
		if a[i] == 1:
			if i % 2 == 0:
				even += 1
			else:
				odd += 1
	if even == odd:
		print(n)
		print(*a)
	elif odd + even > n // 2:
		num = n // 2
		if num % 2 == 1:
			num += 1
		print(num)
		for i in range(num):
			print(1, end=' ')
		print()
	else:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	i = 1
	b = []
	while i < n:
		if a[i] - a[i - 1] != 0:
			if a[i - 1] == 1:
				b.append(a[i])
			else:
				b.append(a[i - 1])
		else:
			b.append(a[i - 1])
			b.append(a[i])
		i += 2
	print(len(b))
	for x in b:
		print(x, end=' ')
	print()
	t -= 1


for s in [*open(0)][2::2]:
	f = '0'.join((x[len(x) % 2:] for x in s[::2].split('0')))
	print(len(f), *f)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c_1 = 0
	c_0 = 0
	for i in a:
		if i == 1:
			c_1 += 1
		else:
			c_0 += 1
	if c_0 >= c_1:
		print(n // 2, end=' ')
		count = 0
		for i in a:
			if count == n // 2:
				break
			elif i == 0:
				print(i, end=' ')
				count += 1
		print()
	else:
		if n // 2 % 2 == 0:
			print(n // 2, end=' ')
			count = 0
			for i in a:
				if count == n // 2:
					break
				elif i == 1:
					print(i, end=' ')
					count += 1
		else:
			print(n // 2 + 1, end=' ')
			count = 0
			for i in a:
				if count == n // 2 + 1:
					break
				elif i == 1:
					print(i, end=' ')
					count += 1
		print()


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	czero = lst.count(0)
	cone = lst.count(1)
	if cone <= n // 2:
		ans = [0 for i in range(n - cone)]
	else:
		ans = [1 for i in range(n - czero)]
		if czero % 2 != 0:
			ans.remove(1)
	print(len(ans))
	print(*ans)


def mapit():
	temp = list(map(int, input().split()))
	return temp

def solution():
	n = int(input())
	arr = mapit()
	sm = sum(arr)
	if sm <= n // 2:
		print(n - sm)
		ans = [0] * (n - sm)
		print(*ans)
	else:
		if sm % 2:
			sm -= 1
		ans = [1] * sm
		print(sm)
		print(*ans)
	return
t = int(input())
while t:
	t -= 1
	solution()


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	l = zz()
	one = l.count(1)
	zerr = l.count(0)
	if zerr >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
		continue
	if n // 2 % 2:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print(1, end=' ')
		print()
		continue
	if one >= n // 2 and n // 2 % 2 == 0:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
		print()
		continue


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	count0 = ar.count(0)
	count1 = ar.count(1)
	if count0 >= count1:
		print(count0)
		print('0 ' * count0)
	else:
		print(count1 // 2 * 2)
		print('1 ' * (count1 // 2) * 2)


for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	cnt = sum(L)
	if (n - cnt) * 2 >= n:
		print(n // 2)
		print(*[0 for i in range(n // 2)])
	else:
		print(cnt - cnt % 2)
		print(*[1 for i in range(cnt - cnt % 2)])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = a.count(0)
	if o > z:
		if o % 2 == 0:
			print(o)
			for i in range(o):
				print(1, end=' ')
		else:
			print(o - 1)
			for i in range(o - 1):
				print(1, end=' ')
	elif z % 2 == 0 or z % 2 == 1:
		print(z)
		for i in range(z):
			print(0, end=' ')
	print()


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def f():
	sys.stdout.flush()

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		cnt0 = a.count(0)
		cnt1 = a.count(1)
		if cnt0 >= cnt1:
			print(cnt0)
			print('0 ' * cnt0)
		else:
			if cnt1 & 1:
				cnt1 -= 1
			print(cnt1)
			print('1 ' * cnt1)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


import sys

def printer(ls):
	print(len(ls))
	print(*ls)
t = int(input())
while t > 0:
	t -= 1
	n = int(sys.stdin.readline())
	input = sys.stdin.readline()
	arr = list(map(int, input.split()))
	zer = 0
	one = 0
	for x in arr:
		if x == 0:
			zer += 1
		else:
			one += 1
	if n % 4 == 0:
		if zer > one:
			ls = [0 for i in range(n // 2)]
			printer(ls)
		else:
			ls = [1 for i in range(n // 2)]
			printer(ls)
	elif zer > one:
		ls = [0 for i in range(n // 2 + 1)]
		printer(ls)
	elif one > zer:
		ls = [1 for i in range(n // 2 + 1)]
		printer(ls)
	else:
		ls = [0 for i in range(n // 2)]
		printer(ls)


testcases = int(input())
for _ in range(testcases):
	n = int(input())
	arr = list(map(int, input().split()))
	o = 0
	z = 0
	for i in arr:
		if i == 0:
			z += 1
		else:
			o += 1
	if z >= o:
		print(z)
		answer = '0 ' * z
	elif o % 2 == 0:
		print(o)
		answer = '1 ' * o
	else:
		print(o - 1)
		answer = '1 ' * (o - 1)
	print(answer[:-1])


import sys
import math

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)
for _ in range(iinp()):
	n = iinp()
	a = linp()
	one = 0
	zero = 0
	for i in a:
		if i == 1:
			one += 1
		else:
			zero += 1
	if zero >= n / 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
	elif n // 2 % 2 == 0:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
	else:
		print((n + 2) // 2)
		for i in range((n + 2) // 2):
			print(1, end=' ')
	print('')


TC = int(input())
for _ in range(TC):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0, 0]
	for x in a:
		cnt[x] += 1
	if cnt[0] >= cnt[1]:
		print(cnt[0])
		print('0 ' * cnt[0])
	else:
		print(cnt[1] - cnt[1] % 2)
		print('1 ' * (cnt[1] - cnt[1] % 2))


for ivc in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	l = ''
	for i in range(n // 3):
		(a, b, c) = (s[3 * i], s[3 * i + 1], s[3 * i + 2])
		if a + b + c > 1:
			l += '1 1 '
		else:
			l += '0 0 '
	if n == 2:
		if s[0] + s[1] < 2:
			l += '0 '
		else:
			l += '1 1 '
	print(l.count(' '))
	print(l)


from collections import Counter
for _ in range(int(input())):
	i_liczb = int(input())
	liczby = list(map(int, input().split()))
	conter = Counter(liczby)
	(ile_0, ile_1) = (conter[0], conter[1])
	if ile_0 >= i_liczb // 2:
		print(ile_0)
		print('0 ' * ile_0)
	else:
		print(ile_1 - ile_1 % 2)
		print('1 ' * (ile_1 - ile_1 % 2))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	el = [0, 0]
	for i in a:
		el[i] += 1
	if el[0] == el[1]:
		print(n // 2)
		print(*[0 for _ in range(n // 2)])
	else:
		ts = n // 2 + n // 2 % 2
		print(ts)
		print(*[int(el[1] > el[0]) for _ in range(ts)])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	zero = 0
	one = 0
	for i in a:
		if i == 1:
			one += 1
		else:
			zero += 1
	if zero >= one:
		print(zero)
		ans = [0] * zero
		print(*ans)
	elif one % 2 == 0:
		ans = [1] * one
		print(one)
		print(*ans)
	else:
		one -= 1
		ans = [1] * one
		print(one)
		print(*ans)


for i in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	if A.count(0) >= A.count(1):
		print(N // 2)
		print('0 ' * (N // 2))
	else:
		print(N // 2 + int(N // 2 % 2 == 1))
		print('1 ' * (N // 2 + int(N // 2 % 2 == 1)))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def integer():
	return int(inp())

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def solve():
	n = int(inp())
	ar = lis()
	c = ar.count(1)
	if c > n // 2:
		if n % 4 == 0:
			print(n // 2)
			print('1 ' * (n // 2))
		elif c >= n // 2 + 1:
			print(n // 2 + 1)
			print('1 ' * (n // 2 + 1))
		else:
			print(n // 2)
			print('1 ' * (n // 2 - 1) + '0')
	else:
		print(n // 2)
		print('0 ' * (n // 2))
testcase(integer())


t = int(input())
for i in range(t):
	n = int(input()) // 2
	a = list(map(str, input().split()))
	if a.count('1') > a.count('0'):
		ans = '1 '
	else:
		ans = '0 '
	if n % 2 == 1 and ans == '1 ':
		n = n + 1
	print(n)
	print(ans * n)


import os, sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	from math import gcd
	for _ in range(int(input())):
		n = int(input())
		mn = 0
		a = [int(X) for X in input().split()]
		x = a.count(1)
		y = n - x
		if x > y:
			if x % 2 == 1:
				print(n - y - 1)
				print(*[1] * (x - 1))
			else:
				print(n - y)
				print(*[1] * x)
		else:
			print(y)
			print(*[0] * y)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def problemA(arr, n):
	count0 = 0
	for i in range(n):
		if arr[i] == 0:
			count0 += 1
	count1 = n - count0
	if count0 >= count1:
		return (n // 2, [0] * (n // 2))
	elif n // 2 % 2 == 0:
		return (n // 2, [1] * (n // 2))
	else:
		return (n // 2 + 1, [1] * (n // 2 + 1))
testCases = input()
for i in range(int(testCases)):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	(nans, ans) = problemA(arr, n)
	print(nans)
	print(' '.join([str(i) for i in ans]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s > n // 2:
		if s % 2 == 0:
			b = [1] * s
		else:
			b = [1] * (s - 1)
	else:
		b = [0] * (n // 2)
	print(len(b))
	print(*b)


from collections import defaultdict
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0, 0]
	for x in a:
		cnt[x] += 1
	if cnt[0] >= n // 2:
		print(cnt[0])
		print('0 ' * cnt[0])
	else:
		print(cnt[1] - cnt[1] % 2)
		print('1 ' * (cnt[1] - cnt[1] % 2))


case = int(input())
for i in range(case):
	input()
	lst = list(map(int, input().split(' ')))
	one = lst.count(1)
	zero = lst.count(0)
	f = 0
	if one <= zero:
		f = 1
	else:
		f = 0
	for x in range(min(one, zero)):
		lst.remove(f)
	if 0 not in lst and len(lst) % 2 == 1:
		lst.remove(1)
	print(len(lst))
	print(*lst)


import sys
input = sys.stdin.readline

def f():
	n = int(input())
	A = list(map(int, input().split()))
	c = sum(A)
	if c <= n // 2:
		print(n - c)
		print(*[0] * (n - c))
	else:
		print(c - c % 2)
		print(*[1] * (c - c % 2))
t = int(input())
for x in range(t):
	f()


def listt(n, a):
	c0 = a.count(0)
	c1 = a.count(1)
	if c1 <= n:
		a = [0] * c0
	elif c0 < n:
		a = [1] * c1
		if len(a) % 2 == 1:
			a.remove(1)
	return a
t = int(input())
for i in range(t):
	n = int(input())
	j = [int(i) for i in input().split()]
	l = listt(n // 2, j)
	print(len(l))
	print(' '.join([str(i) for i in l]))


n = int(input())
for _ in range(n):
	s = int(input())
	mas = list(map(int, input().split()))
	summas = sum(mas)
	if summas <= s / 2:
		print(s - summas)
		print(*[0 for _ in range(s - summas)])
	else:
		count = summas - summas % 2
		print(count)
		print(*[1 for _ in range(count)])


def process():
	n = int(input())
	li = list(map(int, input().split()))
	removed = 0
	l = []
	flag = 0
	lb = -1
	for i in range(0, n):
		if li[i] == 1:
			flag = 1
			lb = i
			for j in range(i + 1, n):
				if li[j] == 1:
					flag = 0
					if i % 2 == j % 2:
						l.append(j - 1)
						removed += 1
					li[j] = '1'
					break
	if flag == 1:
		removed += 1
	else:
		lb = -1
	print(n - removed)
	for i in range(0, n):
		if i != lb and i not in l:
			print(li[i], end=' ')
	print()
tests = int(input())
for i in range(tests):
	process()


for _ in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	c = 0
	s = []
	i = 0
	while i < n - 1:
		if l[i] == 0:
			if l[i + 1] == 0:
				s.append(0)
				s.append(0)
				i += 1
			elif i + 2 < n and l[i + 2] == 0:
				s.append(0)
				s.append(0)
				i += 2
		elif l[i + 1] == 1:
			s.append(1)
			s.append(1)
			i += 1
		elif i + 2 < n and l[i + 2] == 1:
			s.append(1)
			s.append(1)
			i += 2
		i += 1
	if len(s) == 0:
		print(1)
		print(0)
	else:
		print(len(s))
		print(*s)


import sys
n = int(sys.stdin.readline())
for i in range(n):
	s = int(sys.stdin.readline())
	data = [int(i) for i in sys.stdin.readline().split()]
	stack = []
	it = 0
	for (j, value) in enumerate(data):
		if stack and stack[-1][0] == value:
			stack.pop()
		else:
			stack.append((value, j))
	to_drop = set()
	if len(stack) == 0:
		print(len(data))
		print(' '.join((str(v) for v in data)))
	else:
		print(len(data) - 1)
		if len(stack) % 2 == 1:
			to_drop = stack[len(stack) // 2][1]
		elif stack[0][0] == 1:
			to_drop = stack[len(stack) // 2 - 1][1]
		else:
			to_drop = stack[len(stack) // 2][1]
		for (ind, k) in enumerate(data):
			if ind != to_drop:
				print(k, end=' ')
		print('')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = l.count(0)
	b = l.count(1)
	n = n // 2
	if b <= n:
		print(a)
		for i in range(a):
			print(0, end=' ')
	else:
		if b % 2 == 1:
			b -= 1
		print(b)
		for i in range(b):
			print(1, end=' ')
	print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(_) for _ in input().split(' ')]
	ans = []
	zeroes = 0
	ones = 0
	for i in a:
		if i:
			ones += 1
		else:
			zeroes += 1
	if ones > zeroes:
		ans = [1 for _ in range(ones)]
	else:
		ans = [0 for _ in range(zeroes)]
	l = len(ans)
	if l > 1 and l % 2 != 0 and (ans[0] == 1):
		l -= 1
		ans.pop(0)
	print(len(ans))
	print(*ans)


from collections import Counter
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = Counter(a)
	if b[1] > n // 2:
		ans = []
		for j in range(n):
			if a[j] == 1:
				ans.append(a[j])
		if len(ans) % 2 != 0:
			ans.pop()
		print(len(ans))
		for j in ans:
			print(j, end=' ')
	else:
		ans = []
		for j in range(n):
			if a[j] == 0:
				ans.append(a[j])
		print(len(ans))
		for j in ans:
			print(j, end=' ')
	print('')


t = int(input())
for i in range(t):
	ind = []
	dni = []
	n = int(input())
	s = list(map(int, input().split()))
	count = 0
	for j in range(n):
		if s[j] == 0 or j == n - 1:
			if s[j] == 1:
				count += 1
				dni.append(j)
			if count > 1:
				if count % 2 == 0:
					if s[j] == 1:
						for k in range(j - count + 1, j + 1):
							ind.append(k)
					else:
						for k in range(j - count, j):
							ind.append(k)
				elif s[j] == 1:
					for k in range(j - count + 1, j):
						ind.append(k)
				else:
					for k in range(j - count, j - 1):
						ind.append(k)
			count = 0
		elif s[j] == 1:
			count += 1
			dni.append(j)
	nid = []
	for j in dni:
		if j not in ind:
			nid.append(j)
	for j in range(len(nid) - 1, -1, -1):
		s.pop(nid[j])
	print(len(s))
	print(' '.join(list(map(str, s))))


ct = input()
for line in range(int(ct)):
	n = input()
	arr = [int(i) for i in input().split()]
	if arr.count(0) >= arr.count(1):
		test = ['0'] * arr.count(0)
		final = ' '.join(test)
		print(arr.count(0))
	else:
		if arr.count(1) % 2 == 1:
			tt = arr.count(1) - 1
		else:
			tt = arr.count(1)
		test = ['1'] * tt
		final = ' '.join(test)
		print(tt)
	print(final)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(1) <= a.count(0):
		print(n // 2)
		arr = [0] * (n // 2)
		print(*arr)
	if a.count(1) > a.count(0):
		if n % 4 != 0:
			print(n // 2 + 1)
			arr = [1] * (n // 2) + [1]
			print(*arr)
		else:
			print(n // 2)
			arr = [1] * (n // 2)
			print(*arr)


import io, os
inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()

def bf(arr):
	odd = 0
	even = 0
	for i in range(len(arr)):
		if i % 2 == 0:
			even += arr[i]
		else:
			odd += arr[i]
	return abs(even - odd)
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	odd = 0
	even = 0
	for i in range(n):
		if i % 2 == 0:
			even += a[i]
		else:
			odd += a[i]
	bal = abs(even - odd)
	for i in range(n):
		temp = a[0:i] + a[i + 1:n]
		bt = bf(temp)
		if bt < bal:
			bal = bt
			a = temp
			n = len(temp)
		if bal == 0:
			break
	print(len(a))
	print(*a)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = [int(x) for x in input().split()]
		A_new = []
		running_pos = 0
		pos = 0
		while pos < n:
			val = A[pos]
			if val == 0:
				A_new.append(val)
			elif val == 1:
				while pos < n and A[pos] == 1:
					pos += 1
					running_pos += 1
				if running_pos % 2 != 0:
					running_pos -= 1
				while running_pos > 0:
					A_new.append(1)
					running_pos -= 1
				pos -= 1
			pos += 1
		print(len(A_new))
		print(*A_new, sep=' ')
main()


t = int(input())
for j in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	while i < len(l):
		x = l[i]
		y = l[i + 1]
		if x == y:
			i = i + 2
		elif x > y:
			l.pop(i)
			i = i + 1
		else:
			l.pop(i + 1)
			i = i + 1
	print(len(l))
	print(*l)


from collections import Counter
t = int(input())
for _ in range(t):
	d = {}
	s = 0
	n = int(input())
	a = input().split()
	c = Counter(a)
	if c['0'] > c['1']:
		print(int(n / 2))
		p = [0] * int(n / 2)
		print(*p)
	elif c['0'] < c['1']:
		if n / 2 % 2 == 1:
			print(int(n / 2) + 1)
			p = [1] * (int(n / 2) + 1)
			print(*p)
		else:
			print(int(n / 2))
			p = [1] * int(n / 2)
			print(*p)
	else:
		print(int(n / 2))
		p = [0] * int(n / 2)
		print(*p)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = a.count(1)
	if cnt == n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
		continue
	if n // 2 % 2 == 1 and cnt > n // 2:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print(1, end=' ')
		print()
		continue
	if cnt > n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
		print()
		continue
	print(n // 2)
	for i in range(n // 2):
		print(0, end=' ')
	print()


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	i = 0
	while i < n - 1:
		if a[i] == 0:
			ans.append(0)
			i += 1
		elif a[i] == 1 and a[i + 1] == 1:
			ans.append(1)
			ans.append(1)
			i += 2
		else:
			i += 1
	if a[-1] == 0:
		ans.append(0)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	arr = [int(c) for c in input().split()]
	if n == 2:
		if arr[0] == 0 or arr[1] == 0:
			print(1)
			print(0)
		else:
			print(2)
			print(1, 1)
		continue
	if arr.count(1) > n // 2:
		if n // 2 & 1:
			ans = [1] * (n // 2)
			ans.append(1)
			print(len(ans))
			print(*ans)
		else:
			ans = [1] * (n // 2)
			print(len(ans))
			print(*ans)
	elif arr.count(0) > n // 2:
		if n // 2 & 1:
			ans = [0] * (n // 2)
			ans.append(0)
			print(len(ans))
			print(*ans)
		else:
			ans = [0] * (n // 2)
			print(len(ans))
			print(*ans)
	elif arr.count(1) == n // 2:
		ans = [0] * (n // 2)
		print(len(ans))
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = a.count(1)
	q = a.count(0)
	if p > q:
		ans = []
		for i in range(n):
			if a[i] == 1:
				ans.append(1)
		if len(ans) % 2 != 0:
			print(len(ans[1:]))
			print(*ans[1:])
		else:
			print(len(ans))
			print(*ans)
	elif q >= p:
		ans = []
		for i in range(n):
			if a[i] == 0:
				ans.append(0)
		print(len(ans))
		print(*ans)


import math
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	ones = a.count(1)
	zeroes = a.count(0)
	result = []
	if ones <= n / 2:
		result = [0] * zeroes
	else:
		result = [1] * (int(ones / 2) * 2)
	print(len(result))
	print(' '.join((str(num) for num in result)))
	t -= 1


import sys
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
	N = int(input())
	K = N // 2
	A = list(map(int, input().split()))
	ans = []
	if A.count(0) >= K:
		ans = [0] * K
	elif K % 2 == 0:
		ans = [1] * K
	else:
		ans = [1] * (K + 1)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	entries = int(input())
	numbers = list(map(int, input().split()))
	if sum(numbers) > entries / 2:
		n = int(entries / 2)
		remainder = n % 2
		listofzeros = [1] * (n + remainder)
		print(len(listofzeros))
		print(*listofzeros, sep=' ')
	elif sum(numbers) <= entries / 2:
		n = int(entries / 2)
		listofzeros = [0] * n
		print(len(listofzeros))
		print(*listofzeros, sep=' ')


from math import *
from bisect import *
from collections import Counter, defaultdict, deque
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = LI()
	o = 0
	z = 0
	for i in range(n):
		if a[i] == 1:
			o += 1
		else:
			z += 1
	if max(o, z) == z:
		print(z)
		print('0 ' * z)
	else:
		o -= o % 2
		print(o)
		print('1 ' * o)


from collections import Counter
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	n0 = c[0]
	n1 = c[1]
	if n0 >= n / 2:
		print(n0)
		for i in range(0, n0):
			print('0', end=' ')
		print(end='\n')
	else:
		print(n1 - n1 % 2)
		for i in range(0, n1 - n1 % 2):
			print('1', end=' ')
		print(end='\n')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count1 = a.count(1)
	count0 = a.count(0)
	if count0 >= count1:
		print(count0)
		for i in range(count0):
			print(0, end=' ')
		print()
	else:
		p = n // 2 + n // 2 % 2
		print(p)
		for i in range(p):
			print(1, end=' ')
		print()


t = int(input())
test_cases = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	test_cases.append((n, arr))
for case in test_cases:
	(n, arr) = case
	ones = sum(arr)
	if ones <= n // 2:
		remain = n - ones
		result = '0 ' * remain
	else:
		remain = ones - ones % 2
		result = '1 ' * remain
	print(remain)
	print(result)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(n1, n0) = (0, 0)
	for i in a:
		if i == 1:
			n1 += 1
		else:
			n0 += 1
	if n0 >= n1:
		print(n0)
		for i in range(n0):
			print(0, end=' ')
		print()
	elif n1 % 2 == 0:
		print(n1)
		for i in range(n1):
			print(1, end=' ')
		print()
	else:
		n1 = n1 - 1
		print(n1)
		for i in range(n1):
			print(1, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count0 = 0
	count1 = 0
	for i in range(n):
		if a[i] == 1:
			count1 += 1
		else:
			count0 += 1
	if count1 <= n // 2:
		res = [0] * (n - count1)
		print(len(res))
		print(*res)
	else:
		if count1 % 2 != 0:
			res = [1] * (n - count0 - 1)
		else:
			res = [1] * (n - count0)
		print(len(res))
		print(*res)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():

	def solve():
		n = int(input())
		(count0, count1) = (0, 0)
		for num in input().split():
			if num == '0':
				count0 += 1
			else:
				count1 += 1
		if count1 <= n / 2:
			remainingType = '0'
			remainingNumbers = n - count1
		else:
			remainingType = '1'
			remainingNumbers = n - count0
			if count1 & 1:
				remainingNumbers -= 1
		print(remainingNumbers)
		print(' '.join([remainingType] * remainingNumbers))
	t = int(input())
	for i in range(t):
		solve()
BUFFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def print(*args, **kwargs):
	sep = kwargs.pop('sep', ' ')
	file = kwargs.pop('file', sys.stdout)
	atStart = True
	for x in args:
		if not atStart:
			file.write(sep)
		file.write(str(x))
		atStart = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
main()


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	n = ii()
	a = il()
	if a.count(0) >= a.count(1):
		l = [0] * a.count(0)
		print(len(l))
		print(*l)
	elif a.count(1) % 2 != 0:
		l = [1] * (a.count(1) - 1)
		print(len(l))
		print(*l)
	else:
		l = [1] * a.count(1)
		print(len(l))
		print(*l)


for i in range(int(input())):
	n = int(input())
	data = sum([int(x) for x in input().split()])
	if data <= n // 2:
		print(n - data)
		print('0 ' * (n - data))
	else:
		print(data // 2 * 2)
		print('1 ' * (data // 2 * 2))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(c0, c1) = (a.count(0), a.count(1))
	ans = []
	if c1 <= n // 2:
		for i in a:
			if i == 0:
				ans.append(i)
	else:
		flag = 1 if c1 & 1 else 0
		for i in a:
			if flag and i == 1:
				flag = 0
				continue
			if i == 1:
				ans.append(i)
	print(len(ans))
	for i in range(len(ans) - 1):
		print(ans[i], end=' ')
	print(ans[-1])


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(one, zero) = (0, 0)
	for j in range(n):
		if l[j] == 1:
			one += 1
		else:
			zero += 1
	if one <= n // 2:
		print(zero)
		print('0 ' * zero)
	elif one % 2:
		print(one - 1)
		print('1 ' * (one - 1))
	else:
		print(one)
		print('1 ' * one)


def calc(a):
	units = sum(a)
	zeroes = len(a) - units
	if units > zeroes:
		res = [1] * (units - units % 2)
	else:
		res = [0] * zeroes
	return res

def get_ints():
	return [int(n) for n in input().split()]

def get_floats():
	return [float(n) for n in input().split()]

def seq2str(seq):
	return ' '.join((str(item) for item in seq))
zzz = get_ints()
assert len(zzz) == 1
t = zzz[0]
for i in range(t):
	zzz = get_ints()
	assert len(zzz) == 1
	n = zzz[0]
	zzz = get_ints()
	assert len(zzz) == n
	a = zzz
	res = calc(a)
	print(len(res))
	print(seq2str(res))


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	z = aa.count(0)
	if z >= n // 2:
		print(z)
		print('0 ' * z)
	elif (n - z) % 2 == 0:
		print(n - z)
		print('1 ' * (n - z))
	else:
		print(n - z - 1)
		print('1 ' * (n - z - 1))

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


ii = lambda : int(input())
il = lambda : list(map(int, input().split()))
for _ in range(ii()):
	c = 0
	c = 1
	n = ii()
	a = il()
	c = c + 1
	if a.count(0) >= a.count(1):
		l = [0] * a.count(0)
		print(len(l))
		print(*l)
	else:
		c = 0
		if a.count(1) % 2 != 0:
			l = [1] * (a.count(1) - 1)
			print(len(l))
			print(*l)
		else:
			c = 0
			l = [1] * a.count(1)
			print(len(l))
			print(*l)
			c = c + 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c1 = a.count(1)
	c0 = n - c1
	if c0 >= c1:
		print(n // 2)
		print(*[0] * (n // 2))
	elif c1 % 2 == 0:
		print(c1)
		print(*[1] * c1)
	else:
		print(c1 - 1)
		print(*[1] * (c1 - 1))


n = int(input())
for i in range(n):
	l = int(input())
	a = list(map(int, input().split()))
	kol_0 = 0
	kol_1 = 0
	for i in range(len(a)):
		if a[i] == 0:
			kol_0 += 1
		else:
			kol_1 += 1
	otv = []
	if kol_0 >= kol_1:
		otv = [0] * kol_0
	elif kol_1 % 2 == 0:
		otv = [1] * kol_1
	elif kol_1 - kol_0 > 1:
		otv = [1] * (kol_1 - 1)
	elif a[-1] == 0:
		otv = [1] * (kol_1 - 1)
		otv.append(0)
	elif a[0] == 1:
		otv = [1] + [0] * (kol_1 - 1) + [1]
	else:
		otv = [0] + [1] * (kol_1 - 1)
	print(len(otv))
	print(*otv)


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	ans = []
	for i in range(0, n, 2):
		if a[i] + a[i + 1] < 2:
			ans += [0]
		else:
			ans += [1, 1]
	print(len(ans))
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ev = 0
	od = 0
	for i in arr:
		if i == 0:
			ev = ev + 1
		else:
			od = od + 1
	if 2 * ev >= n:
		print(ev)
		for j in range(ev):
			print(0, end=' ')
		print()
	else:
		r = od // 2
		odd = r * 2
		print(odd)
		for j in range(odd):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1:
		print(n)
		print(*a)
	elif a.count(0) >= n // 2:
		ans = [0] * (n // 2)
		print(n // 2)
		print(*ans)
	else:
		res = n // 2
		if res % 2 == 0:
			ans = [1] * (n // 2)
		else:
			ans = [1] * (n // 2 + 1)
		print(len(ans))
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	m = n // 2
	if list1.count(1) > list1.count(0):
		if list1.count(0) != 0:
			if m % 2 == 0:
				print(m)
				print('1 ' * m)
			else:
				print(m + 1)
				print('1 ' * (m + 1))
		else:
			print(n)
			for l in range(n):
				print(list1[l], end=' ')
	elif list1.count(1) < list1.count(0):
		if list1.count(1) != 0:
			print(m)
			print('0 ' * m)
		else:
			print(n)
			for l in range(n):
				print(list1[l], end=' ')
	else:
		print(m)
		print('0 ' * m)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = a.count(1)
	c = n - d
	if c >= d:
		for j in range(n - 1, -1, -1):
			if a[j] == 1:
				del a[j]
	else:
		for j in range(n - 1, -1, -1):
			if a[j] == 0:
				del a[j]
		if d % 2 == 1:
			del a[-1]
	print(len(a))
	print(' '.join(map(str, a)))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	cnt1 = 0
	for i in a:
		if i == 1:
			cnt1 += 1
	(m, e) = (-1, -1)
	if cnt1 <= n >> 1:
		m = n - cnt1
		e = 0
	else:
		m = cnt1
		e = 1
		if m & 1:
			m -= 1
	print(m)
	for i in range(m):
		print(e, end=' ')
	print()
for _ in range(int(input())):
	solve()


import sys, collections, math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	n = int(input())
	arr = get_array()
	z = arr.count(0)
	o = arr.count(1)
	if o <= n // 2:
		print(z)
		print(*[0] * z)
	elif z < n // 2:
		if o % 2 == 0:
			print(o)
			print(*[1] * o)
		else:
			print(o - 1)
			print(*[1] * (o - 1))


import math
t = int(input())
ans = []

def solve(n, arr):
	ones = arr.count(1)
	if ones <= n // 2:
		ans = [0] * (n // 2)
	elif ones % 2 == 0:
		ans = [1] * ones
	else:
		ans = [1] * (ones - 1)
	return ans
	pass
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans.append(solve(n, arr))
for test in ans:
	print(len(test))
	for ele in test:
		print(ele, end=' ')
	print()


def solve(arr, s):
	temp = []
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	if s > n // 2:
		temp = [1] * (2 * (s // 2))
	elif s == 0:
		temp = [0] * n
	elif s == n // 2:
		temp = [0] * s
	else:
		temp = [0] * (2 * ((n - s) // 2))
		if len(temp) == 0:
			temp = [0]
	print(len(temp))
	print(*temp)


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	z = 0
	o = 0
	ans = []
	for i in a:
		if i == 0:
			z += 1
		else:
			o += 1
		if z == 2:
			z = 0
			o = 0
			ans.append(0)
			ans.append(0)
		elif o == 2:
			z = 0
			o = 0
			ans.append(1)
			ans.append(1)
	if z > 0:
		ans.append(0)
	print(len(ans))
	print(*ans)


t = int(input())
for k in range(t):
	n = int(input())
	vect = list(map(int, input().split()))
	S = 0
	for i in range(n):
		if i % 2 == 0:
			S += vect[i]
		else:
			S -= vect[i]
	if S == 0:
		print(n)
		print(*vect)
		continue
	elif S > 0:
		bad = 0
	else:
		bad = 1
	S = abs(S)
	i = n - 1
	while i >= 0 and S > 1:
		if i % 2 == bad and vect[i] == 1:
			j = 1
			while vect[i - j] != 1:
				j += 1
			if (i - j) % 2 == bad:
				vect.pop(i)
				vect.pop(i - j)
				S -= 2
			i = i - j - 1
		else:
			i -= 1
	if S == 0:
		print(len(vect))
		print(*vect)
		continue
	else:
		bads = 0
		goods = 0
		for i in range(len(vect) - 1, -1, -1):
			if vect[i] == 1:
				if i % 2 == bad:
					bads += 1
				else:
					goods += 1
				if bads == goods + 1:
					vect.pop(i)
					break
	print(len(vect))
	print(*vect)


def linput():
	return [int(i) for i in input().split()]

def nod(a, b):
	while a != 0 and b != 0:
		if a > b:
			a = a % b
		else:
			b = b % a
	return a + b
qwertyyyyyy = int(input())
for ______ in range(qwertyyyyyy):
	n = int(input())
	q = linput()
	if q.count(0) >= n // 2:
		print(q.count(0))
		print('0 ' * q.count(0))
	elif q.count(0) % 2 == 0:
		print(n - q.count(0))
		print('1 ' * q.count(1))
	else:
		print(n - q.count(0) - 1)
		print('1 ' * (q.count(1) - 1))


import sys
import math
input = sys.stdin.readline
from collections import deque
from queue import LifoQueue
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(zero, one) = (0, 0)
	for i in range(n):
		if a[i] == 0:
			zero += 1
		else:
			one += 1
			O = i
	if one == zero:
		pp = [0] * zero
		print(zero)
		print(*pp)
	elif one < zero:
		print(zero)
		pp = [0] * zero
		print(*pp)
	elif one % 2 == 1:
		print(one - 1)
		pp = [1] * (one - 1)
		print(*pp)
	else:
		print(one)
		pp = [1] * one
		print(*pp)


def remove(e, ind, arr):
	f = arr[:ind + 1]
	s = arr[ind + 1:]
	s.remove(e)
	return f + s
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n == 2:
		if a[0] != a[1]:
			print(1)
			print(0)
		else:
			print(2)
			print(*a)
		continue
	ans = []
	while n > 1:
		if a[0] != a[1]:
			ones = a.count(1)
			zeroes = a.count(0)
			if ones <= zeroes:
				a.remove(1)
			else:
				a.remove(0)
		else:
			ans += a[:2]
			a = a[2:]
		n = len(a)
	if n == 1:
		if a[0] == 0:
			ans += [0]
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	zero = 0
	one = 0
	for x in data:
		if x == 0:
			zero += 1
		else:
			one += 1
	if zero >= one:
		print(zero)
		for i in range(zero):
			print(0, end=' ')
	else:
		print(one // 2 * 2)
		for i in range(one // 2 * 2):
			print(1, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	a = sum(arr)
	ans = []
	if a <= n / 2:
		print(n - a)
		assert n - a >= n / 2
		for i in range(n - a):
			print(0, end=' ')
	else:
		if a % 2 != 0:
			a -= 1
		print(a)
		assert a >= n / 2
		for i in range(a):
			print(1, end=' ')
	print()


def solution(n, a):
	n_0 = a.count(0)
	if n // 2 <= n_0:
		return [n // 2, [0] * (n // 2)]
	elif n // 2 % 2 == 0:
		return [n // 2, [1] * (n // 2)]
	else:
		return [n // 2 + 1, [1] * (n // 2 + 1)]
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	print(solution(n, a)[0])
	print(*solution(n, a)[1])


t = int(input())
for T in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	cnt1 = l.count(1)
	cnt2 = l.count(0)
	if cnt1 <= n // 2:
		print(cnt2)
		for i in range(cnt2):
			print(0, end=' ')
	else:
		print(cnt1 - cnt1 % 2)
		for i in range(cnt1 - cnt1 % 2):
			print(1, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ones = sum(a)
	if ones <= n // 2:
		print(n - ones)
		print('0 ' * (n - ones))
	else:
		ones = ones - ones % 2
		print(ones)
		print('1 ' * ones)


for i in range(int(input())):
	b = input()
	a = list(map(int, input().split()))
	if a.count(1) <= a.count(0):
		print(a.count(0))
		print(*['0'] * a.count(0), sep=' ')
	else:
		print(a.count(1) - 1 if a.count(1) % 2 else a.count(1))
		print(*['1'] * (a.count(1) - 1 if a.count(1) % 2 else a.count(1)))


def main_function():
	t = int(input())
	data = []
	for i in range(t):
		n = int(input())
		data.append([int(i) for i in input().split(' ')])
	for j in data:
		a = j
		zero_counter = [0, 0]
		one_counter = [0, 1]
		for i in a:
			if i == 0:
				zero_counter[0] += 1
			else:
				one_counter[0] += 1
		s = sorted([zero_counter, one_counter], key=lambda x: (x[0], -x[1]))
		max_val = s[1][1]
		max_count = s[1][0]
		if max_count > len(a) // 2 and max_count % 2 == 1:
			max_count -= 1
		print(max_count)
		for n in range(max_count):
			if n == max_count - 1:
				print(max_val)
			else:
				print(max_val, end=' ')
main_function()


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c1 = a.count(1)
	if c1 > n // 2:
		if n // 2 & 1:
			n += 2
		print(n // 2)
		a1 = [1] * (n // 2)
		print(*a1)
	else:
		print(n // 2)
		a1 = [0] * (n // 2)
		print(*a1)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	zero_count = arr.count(0)
	if zero_count >= n // 2:
		x = n // 2
		print(x)
		for i in range(x):
			print(0, end=' ')
		print()
	else:
		if n // 2 % 2 == 0:
			x = n // 2
		else:
			x = n // 2 + 1
		print(x)
		for i in range(x):
			print(1, end=' ')
		print()


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')

def check(this):
	odd = 0
	even = 0
	for i in range(len(this)):
		if i % 2:
			odd += this[i]
		else:
			even += this[i]
	return odd == even
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	if check(a):
		print(n)
		print(*a)
		continue
	for i in range(n):
		this = a.copy()
		this.pop(i)
		if check(this):
			print(n - 1)
			print(*this)
			break


def haha(n, array):
	zeros = 0
	ones = 0
	for x in array:
		if x == 0:
			zeros += 1
		else:
			ones += 1
	if ones == zeros:
		return [int(n / 2), [0] * int(n / 2)]
	elif ones > zeros:
		if ones % 2 == 0:
			return [ones, [1] * ones]
		else:
			return [ones - 1, [1] * (ones - 1)]
	else:
		return [zeros, [0] * zeros]
t = int(input())
final = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	final.append(haha(n, l))
for _ in range(t):
	print(final[_][0])
	for x in final[_][1]:
		print(x, end=' ')
	print()


test = int(input())
for q in range(test):
	n = int(input())
	x = list(map(int, input().split()))
	y = []
	if n == 2:
		if x[0] != x[1]:
			y.append(0)
		else:
			y.append(x[0])
			y.append(x[0])
	else:
		i = 0
		while i < n:
			if i < n - 1 and x[i] == x[i + 1]:
				y.append(x[i])
				y.append(x[i])
				i += 1
			elif i < n - 2 and x[i] == x[i + 2]:
				y.append(x[i])
				y.append(x[i])
				i += 2
			i += 1
	print(len(y))
	for i in range(len(y)):
		if i != len(y) - 1:
			print(y[i], end=' ')
		else:
			print(y[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	one = a.count(1)
	if one <= n / 2:
		a = [x for x in a if x != 1]
		print(len(a))
		print(*a)
	elif one % 2 == 0:
		a = [x for x in a if x == 1]
		print(len(a))
		print(*a)
	else:
		a = [x for x in a if x == 1]
		a.pop()
		print(len(a))
		print(*a)


def solve():
	n = int(input())
	arr = [int(v) for v in input().split()]
	sm = sum(arr)
	if sm <= n // 2:
		print(n - sm)
		print(*[v for v in arr if not v])
	else:
		ans = [1] * sm
		if sm % 2 != 0:
			ans.pop(-1)
		print(len(ans))
		print(*ans)
t = int(input())
for _ in range(t):
	solve()


from collections import Counter

def B1():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		dicti = dict(Counter(a))
		zeros = ones = 0
		if 0 in dicti:
			zeros = dicti.get(0)
		if 1 in dicti:
			ones = dicti.get(1)
		if ones <= n / 2:
			ans = [0 for i in range(n - ones)]
		elif zeros < n / 2:
			if ones % 2:
				k = zeros + 1
			else:
				k = zeros
			ans = [1 for i in range(n - k)]
		print(len(ans))
		print(*ans)
B1()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[::2]
	c = a[1::2]
	x = []
	for i in range(len(b)):
		if b[i] == c[i] == 1:
			x.append(1)
			x.append(1)
		elif b[i] == c[i] == 0:
			x.append(0)
			x.append(0)
		else:
			x.append(0)
	print(len(x))
	print(*x)


tst = int(input())
t = 1
while t <= tst:
	n = int(input())
	ls = list(map(int, input().split()))
	odd = even = i = 0
	while i < n:
		x = ls[i]
		if x == 1:
			odd += 1
		else:
			even += 1
		i += 1
	if odd == even:
		print(even)
		i = 1
		while i <= even:
			print(0, end=' ')
			i += 1
	elif even > odd:
		print(even)
		i = 1
		while i <= even:
			print(0, end=' ')
			i += 1
	else:
		if odd % 2 == 1:
			odd -= 1
		print(odd)
		i = 1
		while i <= odd:
			print(1, end=' ')
			i += 1
	print('\r')
	t += 1


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	c0 = 0
	c1 = 0
	for i in range(n):
		if ar[i] == 1:
			if i % 2 == 1:
				c1 += 1
			else:
				c0 += 1
	if c1 + c0 <= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print('0', end=' ')
		print()
	elif n // 2 % 2 == 0:
		print(n // 2)
		for i in range(n // 2):
			print('1', end=' ')
		print()
	else:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print('1', end=' ')
		print()


def alterSum(arr, n):
	s = 0
	for i in range(n):
		if i % 2 == 0:
			s += arr[i]
		else:
			s -= arr[i]
	return s
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = alterSum(arr, n)
	if s == 0:
		print(len(arr))
		print(*arr)
	else:
		ones = arr.count(1)
		zeroes = arr.count(0)
		if ones == zeroes:
			print(zeroes)
			temp = [0] * zeroes
			print(*temp)
		elif ones < zeroes:
			print(zeroes)
			temp = [0] * zeroes
			print(*temp)
		elif ones > zeroes:
			if ones % 2 == 0:
				print(ones)
				temp = [1] * ones
				print(*temp)
			else:
				print(ones - 1)
				temp = [1] * (ones - 1)
				print(*temp)


def ans(n, arr):
	one = 0
	zero = 0
	for i in range(n):
		if arr[i] == 1:
			one += 1
		else:
			zero += 1
	if zero >= n // 2:
		return [0] * (n // 2)
	elif n // 2 % 2 == 0:
		return [1] * (n // 2)
	else:
		return [1] * (n // 2 + 1)
t = int(input())
L = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	L.append(ans(n, arr))
for l in L:
	print(len(l))
	print(*l)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	z = A.count(0)
	o = A.count(1)
	if z >= o:
		print(z)
		print(' '.join(map(str, [0] * z)))
	else:
		if o % 2 != 0:
			o -= 1
		print(o)
		print(' '.join(map(str, [1] * o)))


def solve(n, arr):
	zero_count = arr.count(0)
	if zero_count >= n / 2:
		print(zero_count)
		return '0 ' * zero_count
	elif zero_count % 2 == 0:
		print(n - zero_count)
		return '1 ' * (n - zero_count)
	else:
		print(n - zero_count - 1)
		return '1 ' * (n - zero_count - 1)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	if a.count(1) % 2:
		a.pop(a.index(1))
	s = '\n'
	c = l = 0
	for i in a:
		if i:
			s += '0 ' * (c - c % 2) + '1 '
			l += c - c % 2 + 1
			c = 0
		else:
			c += 1
	print(l + c, s + '0 ' * c)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(lst):
	console('----- solving ------')
	console(lst)
	if lst.count('0') >= len(lst) // 2:
		print(len(lst) // 2)
		print(' '.join(['0' for _ in range(len(lst) // 2)]))
		return
	if len(lst) // 2 % 2 == 0:
		length = len(lst) // 2
		print(length)
		print(' '.join(['1' for _ in range(length)]))
	else:
		length = len(lst) // 2 + 1
		print(length)
		print(' '.join(['1' for _ in range(length)]))
	return

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	_ = int(input())
	lst = input().split()
	res = solve(lst)


import io, os
inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().rstrip('\n\r')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	if a.count(0) >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	else:
		if n // 2 % 2 == 1:
			n += 2
		print(n // 2)
		print('1 ' * (n // 2))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ze = a.count(0)
	on = a.count(1)
	ch = '1' if on > ze else '0'
	amo = max(on, ze)
	if ze == amo:
		print(amo)
		print(' '.join([ch] * max(on, ze)))
	else:
		print(amo - amo % 2)
		amo = amo - amo % 2
		print(' '.join([ch] * amo))


def find_sequence(bin, num, seq, right=False):
	index = len(bin) - 1
	rep = 0
	revr = seq[::-1]
	while rep != num:
		if str(bin[index - 1]) + str(bin[index]) == seq:
			rep += 1
		if str(bin[index - 1]) + str(bin[index]) == revr:
			rep -= 1
		index -= 2
	if right:
		bin[index + 2] = -1
	else:
		bin[index + 1] = -1

def create_proper(bin):
	string = ''.join([str(k) for k in bin if k != -1])
	res = ''
	for i in range(len(string)):
		res += string[i] + ' '
	return res[:-1]

def solve(bin_string):
	bin = [int(k) for k in bin_string.split()]
	diff = 0
	for i in range(len(bin)):
		diff += pow(-1, i) * int(bin[i])
	if diff == 0:
		print(len(bin))
		print(create_proper(bin))
	else:
		(positive, even) = (diff > 0, diff % 2 == 0)
		if not even:
			if positive:
				find_sequence(bin, diff // 2 + 1, '10', False)
			else:
				find_sequence(bin, abs(diff) // 2 + 1, '01', True)
		elif positive:
			find_sequence(bin, diff // 2 + 1, '10', True)
		else:
			find_sequence(bin, abs(diff) // 2, '01', False)
		print(len(bin) - 1)
		print(create_proper(bin))

def handle_test():
	tests = []
	num_of_tests = int(input())
	for i in range(num_of_tests):
		length = input()
		test = input()
		tests.append(test)
	for test in tests:
		solve(test)
handle_test()


def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	A = getInts()
	if sum(A) > N // 2:
		ans = [1] * (N // 2)
		if len(ans) % 2 == 1:
			ans.append(1)
			print(N // 2 + 1)
		else:
			print(N // 2)
	else:
		ans = [0] * (N // 2)
		print(N // 2)
	print(*ans)
T = getInt()
for t in range(T):
	solve()


def chek(f):
	a = f[:]
	for i in range(len(a)):
		if i % 2 != 0:
			a[i] = -a[i]
	return bool(sum(a))
N = int(input())
for i in range(N):
	n = int(input())
	a = list(map(int, input().split()))
	while chek(a):
		c = a.count(1)
		if c % 2:
			a.remove(1)
		elif c:
			c = 0
			f = a[:a.index(1)]
			a = a[a.index(1):]
			for j in range(len(a)):
				if a[j]:
					if j % 2 == 0:
						if not c:
							c += 1
						else:
							a = f + a[:j - 1] + a[j:]
							break
					elif c:
						c -= 1
					else:
						a = f + a[:j - 1] + a[j:]
						break
	print(len(a))
	print(*a)


for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	count0 = 0
	count1 = 0
	result = []
	for i in a:
		if i == 0:
			count0 += 1
		else:
			count1 += 1
	if count0 >= count1:
		result = [0] * count0
	elif count1 % 2 == 1:
		result = [1] * (count1 - 1)
	else:
		result = [1] * count1
	print(len(result))
	print(*result)


import itertools
import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlst():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s) - 1])

def invar():
	return map(int, input().split())

def pba(n, a):
	res = []
	if a.count(0) >= a.count(1):
		res = [0] * (n // 2)
	else:
		c = n // 2 + n // 2 % 2
		res = [1] * c
	return res
for _ in range(inp()):
	n = inp()
	a = inlst()
	print(len(pba(n, a)))
	print(*pba(n, a))


t = int(input())
for i in range(t):
	l = int(input())
	a = list(map(int, input().split()))
	n = a.count(1)
	if n == 0:
		print(l)
		for i in range(l):
			print(0, end=' ')
		print()
	elif n == 1:
		print(l - 1)
		for i in range(l - 1):
			print(0, end=' ')
		print()
	elif n == l:
		print(n)
		for i in range(l):
			print(1, end=' ')
		print()
	elif n % 2 == 0 and n >= l // 2:
		print(n)
		for i in range(n):
			print(1, end=' ')
		print()
	elif n % 2 == 0:
		print(l - n)
		for i in range(l - n):
			print(0, end=' ')
		print()
	elif n - 1 >= l // 2:
		print(n - 1)
		for i in range(n - 1):
			print(1, end=' ')
		print()
	else:
		print(l - n)
		for i in range(l - n):
			print(0, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	a = 0
	for i in range(n):
		if li[i] == 0:
			a += 1
	if a >= n // 2:
		print(a)
		print(' '.join(['0'] * a))
	elif n // 2 % 2 == 0:
		print(n // 2)
		print(' '.join(['1'] * (n // 2)))
	else:
		print(n // 2 + 1)
		print(' '.join(['1'] * (n // 2 + 1)))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = a.count(1)
	if c <= n / 2:
		k = n // 2
		print(k)
		for i in range(n // 2):
			print(0, end=' ')
	else:
		c1 = n - c
		if n // 2 % 2 == 1:
			k = n // 2 + 1
			print(k)
			for i in range(n // 2 + 1):
				print(1, end=' ')
		else:
			k = n // 2
			print(k)
			for i in range(n // 2):
				print(1, end=' ')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	n_0 = 0
	n_1 = 0
	c = 0
	for i in l:
		if i == 1:
			n_1 += 1
		else:
			n_0 += 1
	if n_1 <= n // 2:
		print(n_0)
		for i in range(n_0):
			print(0, end=' ')
		print()
	elif n_1 % 2 == 0:
		print(n_1)
		for i in range(n_1):
			print(1, end=' ')
		print()
	else:
		print(n_1 - 1)
		for i in range(n_1 - 1):
			print(1, end=' ')
		print()


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
import math
(t,) = gil()
from collections import Counter
for _ in range(t):
	(n,) = gil()
	a = gil()
	b = Counter(a)
	b[1] = max(0, b.get(1, 0) - (b.get(1, 0) & 1))
	if b.get(0, 0) >= n // 2:
		print(b.get(0))
		print('0 ' * b.get(0))
	elif b.get(1, 0) >= n // 2:
		print(b.get(1))
		print('1 ' * b.get(1))


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	a = arr.count(0)
	b = arr.count(1)
	c = n - a
	if a >= n // 2:
		print(a)
		for i in range(a):
			print(0, end=' ')
		print()
	elif b % 2 == 0:
		print(b)
		for i in range(b):
			print(1, end=' ')
		print()
	else:
		print(b - 1)
		for i in range(b - 1):
			print(1, end=' ')
		print()
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	d = False
	ans = []
	s = 0
	if a.count(0) >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2 - 1) + '0')
	elif a.count(1) > n // 2:
		N = n // 2 + n // 2 % 2
		print(N)
		print('1 ' * (N - 1) + '1')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	while False:
		break
	ek = 0
	less = 0
	for xx in a:
		if xx == 1:
			ek += 1
		else:
			less += 1
		while False:
			break
	if ek <= n // 2:
		print(less)
		for j in range(less):
			print(0, end=' ')
	else:
		while False:
			break
		if less % 2 == 1 and n != 2:
			ek -= 1
		print(ek)
		for j in range(ek):
			print(1, end=' ')
	print('')


t = int(input())
for _ in range(t):
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	count_0 = 0
	count_1 = 0
	for i in numbers:
		if i == 0:
			count_0 += 1
		else:
			count_1 += 1
	if count_0 >= n / 2:
		print(count_0)
		for i in range(count_0):
			print(0, end=' ')
	else:
		print(count_1 - count_1 % 2)
		for i in range(count_1 - count_1 % 2):
			print(1, end=' ')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for j in range(0, n, 2):
		if a[j] == a[j + 1]:
			ans.append(a[j])
			ans.append(a[j + 1])
		else:
			ans.append(0)
	print(len(ans))
	print(*ans)


import sys
from collections import deque
pprint = lambda s: print(' '.join(map(lambda x: str(x), s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(ipnut())):
	n = int(ipnut())
	x = list(map(int, input().split()))
	d = deque()
	for i in x:
		d.append(i)
	ans = []
	while len(d) >= 2:
		one = d.popleft()
		two = d.popleft()
		if one == two:
			ans.append(one)
			ans.append(two)
		elif d:
			t = d.popleft()
			ans.append(t)
			ans.append(t)
		else:
			ans.append(0)
	print(len(ans))
	pprint(ans)


import math
from copy import copy
t = input()
t = int(t)
while t > 0:
	n = input()
	n = int(n)
	s = input()
	a = [int(x) for x in s.split()]
	cnt1 = sum(a)
	cnt0 = len(a) - cnt1
	if cnt0 >= len(a) / 2:
		print(cnt0)
		print(' '.join([str(0) for _ in range(cnt0)]))
	else:
		print(cnt1 - cnt1 % 2)
		print(' '.join([str(1) for _ in range(cnt1 - cnt1 % 2)]))
	t -= 1


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	hash = defaultdict(int)
	for i in l:
		hash[i] += 1
	if hash[0] == hash[1]:
		print(n // 2)
		print(*[0] * (n // 2))
	elif hash[0] > hash[1]:
		print(hash[0])
		print(*[0] * hash[0])
	elif hash[1] % 2 == 0:
		print(hash[1])
		print(*[1] * hash[1])
	else:
		print(hash[1] - 1)
		print(*[1] * (hash[1] - 1))


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	x = arr.count(0)
	y = arr.count(1)
	if x >= n / 2:
		print(x)
		for j in range(x):
			print('0', end=' ')
		print('')
	elif y % 2 == 0:
		print(y)
		for j in range(y):
			print('1', end=' ')
		print('')
	else:
		print(y - 1)
		for j in range(y - 1):
			print('1', end=' ')
		print('')


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(b, jj) = ([], 0)
	while jj < n - 1:
		if a[jj] == 0:
			b.append(0)
		elif a[jj] == a[jj + 1] == 1:
			b.extend([1, 1])
			jj += 1
		jj += 1
	if a[-1] == 0:
		b.append(0)
	print(len(b))
	print(*b)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c1 = l.count(0)
	c2 = l.count(1)
	if c2 <= n // 2:
		for i in range(c2):
			l.remove(1)
	elif c1 < n // 2:
		for i in range(c1):
			l.remove(0)
		if c2 % 2 == 1:
			l.remove(1)
	print(len(l))
	print(' '.join(map(str, l)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	for i in range(0, n, 2):
		if l[i] == 0 and l[i + 1] == 1:
			ans.append(0)
		elif l[i + 1] == 0 and l[i] == 1:
			ans.append(0)
		else:
			ans.append(l[i])
			ans.append(l[i + 1])
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	zcount = lis.count(0)
	ocount = n - zcount
	if zcount >= n // 2:
		print(zcount)
		print('0 ' * zcount)
	else:
		if ocount & 1:
			ocount -= 1
		print(ocount)
		print(ocount * '1 ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ze = a.count(0)
	on = a.count(1)
	if ze >= on:
		print(ze)
		print('0 ' * ze)
	elif on % 2 == 0:
		print(on)
		print('1 ' * on)
	elif on % 2 != 0:
		print(on - 1)
		print('1 ' * (on - 1))


t = int(input())

def passes(a):
	return sum(a[::2]) - sum(a[1::2]) == 0
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	num1s = a.count(1)
	if num1s * 2 <= n:
		print(n - num1s)
		print(*[0] * (n - num1s))
		continue
	if num1s % 2 == 0:
		print(num1s)
		print(*[1] * num1s)
		continue
	for i in range(n):
		save = a[i]
		del a[i]
		if passes(a):
			print(len(a))
			print(*a)
			break
		a.insert(i, save)
	else:
		raise Exception


ntest = int(input())
for test in range(ntest):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	for i in range(0, n - 3, 4):
		if sum(a[i:i + 4]) >= 3:
			res.extend([1, 1])
		else:
			res.extend([0, 0])
	if n % 4 == 2:
		if sum(a[-2:]) == 2:
			res.extend([1, 1])
		else:
			res.extend([0])
	print(len(res))
	print(' '.join(map(str, res)))


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	if a.count(0) >= n // 2:
		print(n // 2, '0 ' * (n // 2))
	else:
		print(n // 2 + n // 2 % 2, '1 ' * (n // 2 + n // 2 % 2))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	z = a.count(0)
	o = a.count(1)
	if z >= n // 2:
		print(z)
		for i in range(z):
			print(0, end=' ')
	elif o > n // 2:
		print(n // 2 + n // 2 % 2)
		if n // 2 % 2 != 0:
			print(1, end=' ')
		for i in range(n // 2):
			print(1, end=' ')
	print('')


for i in range(int(input())):
	n = int(input())
	a = input().split()
	k = a.count('0')
	l = a.count('1')
	r = ''
	if n % 2 == 0:
		if k >= l:
			f = k
			for i in range(k):
				r += '0' + ' '
		else:
			if l % 2 != 0:
				l -= 1
			f = l
			for i in range(l):
				r += '1' + ' '
	elif k > l:
		f = k
		for i in range(k):
			r += '0' + ' '
	elif l == int(n / 2) + 1:
		r = '0 '
		f = l
		for i in range(l - 1):
			r += '1' + ' '
	elif l % 2 != 0:
		l -= 1
		f = l
		for i in range(l):
			r += '1' + ' '
	else:
		f = l
		for i in range(l):
			r += '1' + ' '
	print(f)
	print(r)


import math
test = int(input())
for t in range(test):
	n = int(input())
	A = list(map(int, input().split()))
	if A.count(0) >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	elif A.count(1) > n // 2:
		if n // 2 % 2 != 0:
			print(n // 2 + 1)
			print('1 ' * (n // 2 + 1))
		else:
			print(n // 2)
			print('1 ' * (n // 2))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(0, n, 2):
		if a[i] - a[i + 1] == 0:
			b.append(a[i])
			b.append(a[i + 1])
		elif a[i] == 0:
			b.append(a[i])
		elif a[i + 1] == 0:
			b.append(a[i + 1])
	print(len(b))
	print(*b)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		r = []
		for i in range(n // 3):
			s = sum(a[i * 3:i * 3 + 3])
			if s >= 2:
				r.extend([1, 1])
			else:
				r.extend([0, 0])
		if n % 3 == 2:
			s = sum(a[-2:])
			if s == 2:
				r.extend([1, 1])
			else:
				r.extend([0])
		rr.append(len(r))
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	n = int(ii())
	data = idata()
	ans = [data[0]]
	count = data[0]
	for i in range(1, n):
		if ans[-1] == 1 and data[i] == 0 and (count == 1):
			ans[-1] = 0
			count = 0
		else:
			ans += [data[i]]
			count = (count + data[i]) % 2
	if count == 1 and ans[-1] == 1:
		ans.pop(len(ans) - 1)
	print(len(ans))
	print(*ans)
	return
for t in range(int(ii())):
	solve()


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		(a0, a1) = (a.count(0), a.count(1))
		if a0 >= a1:
			print(a0)
			print(*[0] * a0)
		else:
			if a1 % 2 == 1:
				a1 -= 1
			print(a1)
			print(*[1] * a1)
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	s = 0
	one = l.count(1)
	zero = n - one
	if n // 2 & 1 and one > n // 2:
		print(n // 2 + 1)
		print(*[1] * (n // 2 + 1))
	elif not n // 2 & 1 and one >= n // 2:
		print(n // 2)
		print(*[1] * (n // 2))
	elif zero >= n // 2:
		print(n // 2)
		print(*[0] * (n // 2))


T = input()
T = int(T)
for t in range(T):
	n = int(input())
	arr = [int(v) for v in input().split()]
	zeros_count = 0
	ones_count = 0
	for a in arr:
		if a:
			ones_count += 1
		else:
			zeros_count += 1
	if ones_count > zeros_count:
		res = ' '.join(['1' for _ in range(ones_count - ones_count % 2)])
	else:
		res = ' '.join(['0' for _ in range(zeros_count)])
	k = (len(res) + 1) // 2
	print(k)
	print(res)


def op(val, n):
	print(n)
	for i in range(n):
		print(val, end=' ')
	print()
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = a.count(1)
	y = n - x
	if y >= n // 2:
		op(0, y)
	elif x % 2 == 0:
		op(1, x)
	else:
		op(1, x - 1)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	zs = s.count(0)
	os = s.count(1)
	k = n // 2
	k += k % 2
	if zs >= k:
		print(k)
		print('0 ' * k)
	elif os >= k:
		print(k)
		print('1 ' * k)
	else:
		print(n // 2)
		print('0 ' * (n // 2))


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list()
	zero = 0
	one = 0
	for i in a:
		if i == '0':
			zero = zero + 1
		else:
			one = one + 1
	if one > zero:
		c = one if one % 2 == 0 else one - 1
		f = '1'
	else:
		c = zero
		f = '0'
	res = ''
	for i in range(c):
		res = res + f + ' '
	print(c)
	print(res)
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input = sys.stdin.readline
import random
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	n = inin()
	l = ain()
	c1 = l.count(1)
	c0 = l.count(0)
	if c1 > n // 2:
		if n % 4 == 0:
			print(n // 2)
			print(*[1] * (n // 2))
		else:
			print(n // 2 + 1)
			print(*[1] * (n // 2 + 1))
	elif c0 > n // 2:
		if n % 4 == 0:
			print(n // 2)
			print(*[0] * (n // 2))
		else:
			print(n // 2 + 1)
			print(*[0] * (n // 2 + 1))
	else:
		print(n // 2)
		print(*[0] * (n // 2))


for i in range(int(input())):
	n = int(input())
	l = [int(c) for c in input().split()]
	c1 = 0
	c2 = 0
	t = []
	p = []
	for i in range(n):
		if l[i] == 1:
			t.append(i)
			c1 += 1
		else:
			p.append(i)
			c2 += 1
	if c1 == c2:
		print(c1)
		l = [0] * c1
		print(*l)
	elif c1 > c2:
		if c1 % 2 == 0:
			print(c1)
			l = [1] * c1
			print(*l)
		else:
			c1 -= 1
			print(c1)
			l = [1] * c1
			print(*l)
	else:
		print(c2)
		l = [0] * c2
		print(*l)


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	a = L()
	o = 0
	e = 0
	for i in range(n):
		if a[i] == 1:
			o += 1
		else:
			e += 1
	if o == e:
		print(e)
		print('0 ' * e)
	elif o > e:
		if o % 2 == 0:
			print(o)
			print('1 ' * o)
		else:
			print(o - 1)
			print('1 ' * (o - 1))
	elif e % 2 == 0:
		print(e)
		print('0 ' * e)
	else:
		print(e - 1)
		print('0 ' * (e - 1))
for _ in range(I()):
	solve()


def main():
	t = int(input())
	while t > 0:
		n = int(input())
		li2 = []
		li = list(map(int, input().split()))
		i = 0
		cnt = 0
		if n == 2:
			if li[0] == li[1]:
				li2.append(li[0])
				li2.append(li[1])
			else:
				li2.append(0)
		else:
			while i < n and cnt <= n // 2 and (len(li2) < n // 2):
				if li[i] == li[i + 1]:
					li2.append(li[i])
					li2.append(li[i + 1])
					i = i + 2
				elif li[i] != li[i + 1] and cnt <= n // 2:
					a = li[i]
					b = li[i + 1]
					c = li[i + 1 + 1]
					cnt = cnt + 1
					if c == a:
						li2.append(c)
						li2.append(a)
					elif c == b:
						li2.append(c)
						li2.append(b)
					i = i + 3
		print(len(li2))
		for i in li2:
			print(i, end=' ')
		print()
		t -= 1
main()


t = 1
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	(ones, zero) = (a.count(1), a.count(0))
	if ones > zero:
		print(ones - ones % 2)
		for i in range(ones - ones % 2):
			print(1, end=' ')
	else:
		print(zero)
		for i in range(zero):
			print(0, end=' ')
	print()


def zeroSum(a):
	if a.count(1) <= len(a) / 2:
		x = [0 for i in range(a.count(1), len(a))]
	else:
		x = [1 for i in range(a.count(1))]
	if 1 in x and len(x) % 2 == 1:
		x.pop()
	return x
trials = int(input())
for i in range(trials):
	n = int(input())
	binary = list(map(int, input().strip().split()))
	ans = zeroSum(binary)
	print(f"{len(ans)}\n{' '.join(map(str, ans))}")


import sys
import random
from fractions import Fraction
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

def flinput():
	return list(fiinput())

def rlinput():
	return list(map(int, input().split()))

def trinput():
	return tuple(rinput())

def srlinput():
	return sorted(list(map(int, input().split())))

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	q = rlinput()
	o = q.count(1)
	z = n - o
	if o > n // 2:
		res = n - z - o % 2
		print(res)
		print('1 ' * res)
	else:
		res = n - o
		print(res)
		print('0 ' * res)
for TESTING in range(iinput()):
	main()


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	q = int(input())
	w = list(map(int, input().split()))
	e = w.count(1)
	r = w.count(0)
	if e > r:
		if e % 2 == 0:
			print(e)
			print(*[1] * e)
		else:
			print(e - 1)
			print(*[1] * (e - 1))
	else:
		print(r)
		print(*[0] * r)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	cnt1 = 0
	for i in a:
		if i:
			cnt1 += 1
	cnt0 = n - cnt1
	if cnt0 >= n // 2:
		print(cnt0)
		for i in range(cnt0):
			print(0, end=' ')
	else:
		print(cnt1 - cnt1 % 2)
		for i in range(cnt1 - cnt1 % 2):
			print(1, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	zero = a.count(0)
	one = a.count(1)
	if zero >= n // 2:
		print(zero)
		for _ in range(zero):
			print('0', end=' ')
	elif one >= n // 2:
		if n // 2 % 2 != 0:
			print(n // 2 + 1)
			for _ in range(n // 2 + 1):
				print('1', end=' ')
		else:
			print(n // 2)
			for _ in range(n // 2):
				print('1', end=' ')
	print()


t = int(input())
for h in range(t):
	n1 = int(input())
	n = list(map(int, input().split()))
	s = 0
	i = 0
	while i != n1:
		if n[i] != n[i + 1]:
			s += 1
			if n[i] == 1:
				n[i] = 3
			else:
				n[i + 1] = 3
		i += 2
	for j in range(s):
		n.remove(3)
	print(len(n))
	print(*n)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	ans = []
	for i in range(0, n, 2):
		if a[i] == a[i + 1]:
			ans.append(a[i])
			ans.append(a[i + 1])
		else:
			ans.append(0)
	print(len(ans))
	print(*ans)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	z = arr.count(0)
	k = len(arr) // 2
	if z >= k:
		ns = (z, ' '.join(['0'] * z))
	elif k % 2 == 0:
		ns = (k, ' '.join(['1'] * k))
	else:
		ns = (k + 1, ' '.join(['1'] * (k + 1)))
	ans.append(ns)
for i in range(t):
	ns = ans[i]
	print(ns[0])
	print(ns[1])


def altSum():
	n = int(input())
	c = 0
	list1 = list(map(int, input().split()))
	list2 = []
	for i in range(0, len(list1)):
		if list1[i] == 0:
			if c == 1:
				c = 0
			list2.append(0)
		elif list1[i] == 1:
			if c == 1:
				list2.append(1)
				list2.append(1)
				c = 0
			else:
				c = 1
	print(len(list2))
	print(*list2, sep=' ')
t = int(input())
for i in range(t):
	altSum()


def solve(n, a):
	c = 0
	for i in a:
		if i == 0:
			c += 1
	if c >= n // 2:
		return (c, '0 ' * c)
	elif (n - c) % 2 == 0:
		return (n - c, '1 ' * (n - c))
	else:
		return (n - c - 1, '1 ' * (n - c - 1))
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = list(solve(n, a))
	print(ans[0])
	print(ans[1])


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	n = int(I1())
	a = list(I())
	c0 = a.count(0)
	c1 = a.count(1)
	if c0 >= n // 2:
		print(c0)
		for i in range(c0):
			print(0, end=' ')
		print()
	else:
		if c1 % 2 != 0:
			c1 -= 1
		print(c1)
		for i in range(c1):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(z, o) = (0, 0)
	for i in l:
		z += i == 0
		o += i == 1
	if z >= o:
		print(n >> 1)
		print('0 ' * (n >> 1))
	elif n >> 1 & 1:
		print((n >> 1) + 1)
		print('1 ' * (1 + (n >> 1)))
	else:
		print(n >> 1)
		print('1 ' * (n >> 1))


import sys

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
testCases = int(input())
while testCases != 0:
	n = int(input())
	a = get_list()
	x = 0
	y = 0
	for i in a:
		if i == 0:
			x += 1
		else:
			y += 1
	if x >= n // 2:
		print(x)
		print('0 ' * x)
	else:
		print(y - y % 2)
		print('1 ' * (y - y % 2))
	testCases -= 1


from sys import stdin
from collections import defaultdict
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	if a.count(0) >= a.count(1):
		print(n // 2)
		out = [0] * (n // 2)
		print(*out)
	elif n // 2 % 2 != 0:
		print(n // 2 + 1)
		out = [1] * (n // 2 + 1)
		print(*out)
	else:
		print(n // 2)
		out = [1] * (n // 2)
		print(*out)


for i in range(int(input())):
	print('\n')
	n = int(input())
	a = list(map(int, input().split()))
	c = []
	for i in range(1, n, 2):
		if a[i] - a[i - 1] != 0:
			c.append(0)
		else:
			c.append(a[i - 1])
			c.append(a[i])
	print(len(c))
	for i in range(len(c)):
		print(c[i], end=' ')


t = int(input())
for j in range(t):
	n = int(input())
	lista = list(map(int, input().split()))
	count1 = 0
	count0 = 0
	for i in range(n):
		if lista[i] == 1:
			count1 += 1
		else:
			count0 += 1
	if count1 <= count0:
		print(count0)
		for i in range(count0):
			print(0, end=' ')
		print()
	elif count1 % 2 == 0:
		print(count1)
		for i in range(count1):
			print(1, end=' ')
		print()
	else:
		print(count1 - 1)
		for i in range(count1 - 1):
			print(1, end=' ')
		print()


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mapi())
	zero = a.count(0)
	one = a.count(1)
	if one > zero:
		print(1 * (n // 2 + (n % 4 != 0)))
		print(*[1] * (n // 2 + (n % 4 != 0)))
	else:
		print(n // 2)
		print(*[0] * (n // 2))


def f(x):
	pass
t = int(input())
for u in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = l.count(1)
	if x <= n // 2:
		print(n - x)
		print(*[0] * (n - x))
	elif n // 2 % 2 == 0:
		print(n // 2)
		print(*[1] * (n // 2))
	else:
		print(n // 2 + 1)
		print(*[1] * (n // 2 + 1))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	one = 0
	zer = 0
	for i in range(n):
		one += int(arr[i] == 1)
		zer += int(arr[i] == 0)
	if one == zer:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	elif one > zer:
		if one % 2 == 0:
			print(one)
			for i in range(one):
				print(1, end=' ')
		else:
			print(one - 1)
			for i in range(one - 1):
				print(1, end=' ')
		print()
	else:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()


import math
for test in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	val_after = []
	curr = 0
	for i in range(n):
		curr += (-1) ** i * a[i]
	if curr != 0:
		val = 0
		prev_val = 0
		for (idx, i) in reversed(list(enumerate(a))):
			val = i * (-1) ** idx
			temp = val + prev_val * 2
			if temp == curr:
				a.pop(idx)
				break
			else:
				prev_val += val
	print(len(a))
	for i in a:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	(cnt0, cnt1) = (0, 0)
	k = 0
	for i in arr:
		if i == 0:
			cnt0 += 1
		else:
			cnt1 += 1
	if cnt0 >= cnt1:
		ans = [0] * cnt0
		k = cnt0
	elif cnt1 % 2 == 0:
		ans = [1] * cnt1
		k = cnt1
	else:
		ans = [1] * cnt1
		if cnt1 - 1 >= n // 2:
			ans.remove(1)
			k = cnt1 - 1
		else:
			ans.insert(arr.find(0), 0)
			k = cnt1 + 1
	print(k)
	print(*ans)


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	(on, ze) = (0, 0)
	for i in range(n):
		if arr[i] == 1:
			on += 1
		else:
			ze += 1
	if on <= n // 2:
		print(n - on)
		for i in range(n - on):
			print(0, end=' ')
		print()
	elif ze % 2:
		print(on - 1)
		for i in range(on - 1):
			print(1, end=' ')
		print()
	else:
		print(n - ze)
		for i in range(n - ze):
			print(1, end=' ')
		print()


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	ans = []
	c = a.count(0)
	if c < n // 2:
		if c % 2 == 0:
			for i in range(n):
				if a[i] != 0:
					ans.append(a[i])
		else:
			boo = False
			for i in range(n):
				if boo == True and a[i] == 1:
					ans.append(a[i])
				elif boo == False and a[i] == 1:
					boo = True
	else:
		for i in range(n):
			if a[i] != 1:
				ans.append(a[i])
	print(len(ans))
	print(*ans)


t = int(input())
for i in range(t):
	a = []
	n = int(input())
	a = [int(a) for a in input().split()]
	x = a.count(1)
	y = a.count(0)
	if n == 2:
		if a.count(1) == 1:
			print('1')
			print('0')
			continue
		else:
			print('2')
			[print(f, end=' ') for f in a]
			print(' ')
			continue
	if y >= n / 2:
		for j in range(n):
			if a[j] == 1:
				a[j] = 4
	elif x > n / 2:
		for j in range(n):
			if a[j] == 0:
				a[j] = 4
		if a.count(1) % 2 == 1:
			a[a.index(1)] = 4
	print(len(a) - a.count(4))
	for j in range(len(a)):
		if a[j] != 4:
			print(a[j], end=' ')
	print(' ')


for _ in range(int(input())):
	(n, a) = (int(input()), [x for x in input().split()])
	if a.count('0') >= n // 2:
		print(a.count('0'), '0 ' * a.count('0'), sep='\n')
	else:
		p = '1 ' * (a.count('1') - a.count('1') % 2)
		print(len(p.split()), p, sep='\n')


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(s, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if s[mid] == val:
			return mid
		elif s[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, s):
	for i in range(1, n):
		s[i] += s[i - 1]
	return s

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
for _ in range(ii1()):
	n = ii1()
	arr = iia()
	s = 0
	idx = n
	ans = 0
	zero = arr.count(0)
	if zero >= n // 2:
		print(n // 2)
		res = [0] * (n // 2)
		print(*res)
		continue
	ones = n - zero
	if ones > n // 2:
		if n // 2 % 2 == 0:
			print(n // 2)
			res = [1] * (n // 2)
			print(*res)
		else:
			print(n // 2 + 1)
			res = [1] * (n // 2 + 1)
			print(*res)
		continue
	for i in range(n):
		if i % 2 == 0:
			ans += arr[i]
		else:
			ans -= arr[i]
		if i >= n // 2 and ans == 0:
			idx = i
			break
	print(idx)
	for i in range(idx):
		print(arr[i], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	ar = [int(k) for k in input().split()]
	ans = []
	for k in range(n // 4):
		tmp = ar[4 * k:4 * k + 4].count(1)
		if tmp < 3:
			ans += [0, 0]
		else:
			ans += [1, 1]
	if n % 4 == 2:
		if [ar[-1], ar[-2]].count(1) < 2:
			ans.append(0)
		else:
			ans += [1, 1]
	print(len(ans))
	for k in ans:
		print(k, end=' ')
	print('')


def solve(arr, n):
	count_zero = 0
	count_one = 0
	for x in arr:
		if x == 0:
			count_zero += 1
		else:
			count_one += 1
	if count_one > count_zero:
		if count_one & 1 == 0:
			return ones(count_one)
		else:
			return ones(count_one - 1)
	elif count_zero & 1 == 0:
		return zeros(count_zero)
	else:
		return zeros(count_zero)

def ones(a):
	return [1 for i in range(a)]

def zeros(b):
	return [0 for i in range(b)]
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	x = solve(arr, n)
	print(len(x))
	for i in x:
		print(int(i), end=' ')


n = int(input())
for i in range(n):
	nn = int(input())
	j = list(map(int, input().split()))
	ones = j.count(1)
	zeros = j.count(0)
	if zeros >= nn / 2:
		print(zeros)
		temp = ['0 ' for i in range(0, zeros)]
		print(''.join(temp).strip())
	else:
		print(ones - ones % 2)
		temp = ['1 ' for i in range(0, ones - ones % 2)]
		print(''.join(temp).strip())


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	no = a.count(1)
	nz = a.count(0)
	if nz >= no:
		print(nz)
		print(*[0] * nz)
	elif no % 2 == 0:
		print(no)
		print(*[1] * no)
	else:
		print(no - 1)
		print(*[1] * (no - 1))


N = int(input())
cnt0 = 0
for i in range(N):
	t = int(input())
	a = list(map(int, input().split()))
	cnt0 = a.count(0)
	cnt1 = t - cnt0
	ans = []
	if cnt0 >= t // 2:
		for j in range(cnt0):
			ans.append(0)
		print(cnt0)
		print(*ans)
	else:
		for j in range(cnt1 - cnt1 % 2):
			ans.append(1)
		print(cnt1 - cnt1 % 2)
		print(*ans)


from math import *
t = int(input())
for q in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	odd = 0
	even = 0
	for i in range(0, n, 2):
		odd = odd + li[i]
	for j in range(1, n, 2):
		even = even + li[j]
	if odd == even:
		print(n)
		print(*li)
	else:
		new_li = []
		no_one = li.count(1)
		no_zero = li.count(0)
		if no_one < int(n / 2) or no_one == int(n / 2):
			for k in li:
				if k == 0:
					new_li.append(k)
		elif no_one > n / 2:
			for k in li:
				if k == 1:
					new_li.append(k)
			if len(new_li) % 2 != 0:
				new_li.remove(1)
		print(len(new_li))
		print(*new_li)


for i in range(int(input())):
	a = int(input()) // 2
	b = input().split()
	if b.count('0') < b.count('1'):
		x = '1 '
		if a % 2 == 1:
			a += 1
	else:
		x = '0 '
	print(a)
	print(a * x)


for _ in range(int(input())):
	lens = int(input())
	arrs = [int(x) for x in input().split()]
	ones = sum(arrs)
	zero = lens - ones

	def print_arr(ch, times):
		for i in range(times):
			print(ch, end=' ')
		print()
	if ones > zero:
		if ones % 2:
			ones -= 1
		print(ones)
		print_arr('1', ones)
	else:
		print(zero)
		print_arr('0', zero)


for _ in range(int(input())):
	c = int(input())
	a = list(map(int, input().split()))
	ones = a.count(1)
	zero = a.count(0)
	flag = 0
	if zero < ones:
		flag = 1
		co = ones
	else:
		co = zero
	if co % 2 and co > c / 2:
		co = co - 1
	print(co)
	if flag:
		for i in range(co):
			print(1, end=' ')
	else:
		for i in range(co):
			print(0, end=' ')


import sys
sys.setrecursionlimit(10 ** 8)
try:
	FILE_POINTER = open('input.inpt')
	input = FILE_POINTER.readline
except:
	FILE_POINTER = None
	input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	k = 0
	for i in range(0, n, 2):
		if arr[i] == 0 and arr[i + 1] == 1:
			arr[i + 1] = -1
			k += 1
		elif arr[i] == 1 and arr[i + 1] == 0:
			arr[i] = -1
			k += 1
	print(n - k)
	for i in range(n):
		if arr[i] != -1:
			print(arr[i], end=' ')
	print()
if FILE_POINTER:
	FILE_POINTER.close()


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ct1 = sum(A)
	ct0 = N - ct1
	rem = 0
	if ct1 <= N // 2:
		print(ct0)
		print(*[0] * ct0, sep=' ')
	else:
		rem = ct1 - ct1 % 2
		print(rem)
		print(*[1] * rem, sep=' ')


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	ans = ''
	oneCt = 0
	length = n
	for i in range(n):
		if a[i] == '1':
			oneCt += 1
	zeroCt = n - oneCt
	if oneCt > zeroCt:
		if oneCt % 2 == 0:
			print(length - zeroCt)
			print('1 ' * oneCt)
		else:
			print(length - zeroCt - 1)
			print('1 ' * (oneCt - 1))
	else:
		print(length - oneCt)
		print('0 ' * zeroCt)


def ans():
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = a.count(0)
	if z >= o:
		print(z, end='\n')
		l = [0 for i in range(z)]
		print(*l)
	else:
		if o & 1:
			o -= 1
		print(o, end='\n')
		l = [1 for i in range(o)]
		print(*l)

def solve():
	for _ in range(int(input())):
		ans()
solve()


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = [0] * T
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	total = sum(A)
	if total <= N // 2:
		print(N // 2)
		print(*[0] * (N // 2))
	elif N // 2 % 2 == 0:
		print(N // 2)
		print(*[1] * (N // 2))
	else:
		print(N // 2 + 1)
		print(*[1] * (N // 2 + 1))


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	one = 0
	zero = 0
	for i in range(n):
		if a[i] == 0:
			zero += 1
		else:
			one += 1
	if zero >= n // 2:
		print(n // 2)
		for j in range(n // 2):
			print('0', end=' ')
	elif n // 2 % 2 != 0:
		print(n // 2 + 1)
		for k in range(n // 2 + 1):
			print('1', end=' ')
	else:
		print(n // 2)
		for l in range(n // 2):
			print('1', end=' ')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	if n == 2:
		x = arr.count(0)
		y = arr.count(1)
		if x == y:
			print(1)
			print(0)
		else:
			print(2)
			for item in arr:
				print(item, end=' ')
			print('')
	elif n % 4 == 0:
		if arr.count(0) > arr.count(1):
			print(n // 2)
			for _ in range(n // 2):
				print(0, end=' ')
			print('')
		else:
			print(n // 2)
			for _ in range(n // 2):
				print(1, end=' ')
			print('')
	else:
		x1 = arr.count(0)
		x2 = arr.count(1)
		p = n // 2 - 1
		if x1 > x2:
			print(n - p)
			for _ in range(n - p):
				print(0, end=' ')
			print('')
		elif x2 > x1:
			print(n - p)
			for _ in range(n - p):
				print(1, end=' ')
			print('')
		else:
			print(n // 2)
			for _ in range(n // 2):
				print(0, end=' ')
			print('')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0, 0]
	for i in a:
		if i == 0:
			c[0] += 1
		else:
			c[1] += 1
	if c[1] <= n // 2:
		a = [i for i in a if i == 0]
		print(len(a))
		print(*a)
	else:
		a = [i for i in a if i == 1]
		if len(a) % 2 != 0:
			a.pop()
		print(len(a))
		print(*a)


import math
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	co = 0
	c1 = 0
	for i in range(n):
		if a[i] == 0:
			co += 1
		else:
			c1 += 1
	if co >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	elif c1 >= n / 2:
		if n % 4 == 0:
			print(n // 2)
			for i in range(n // 2):
				print(1, end=' ')
			print()
		else:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ')
			print()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()[:n]]
	k = 0
	if n == 1:
		if a[0] == 1 and a[1] == 1:
			print(2)
			print('1 1')
		else:
			print(1)
			print(0)
	else:
		while k < len(a) - 1:
			if k % 2 == 0:
				if a[k] != a[k + 1]:
					if a[k] == 1:
						a[k] = 5
						k += 1
					else:
						a[k + 1] = 5
						k += 1
				else:
					k += 1
					pass
			else:
				k += 1
				pass
		x = []
		j = 0
		while j < n:
			if a[j] != 5:
				x.append(a[j])
			j += 1
		print(len(x))
		for l in range(len(x)):
			if l == len(x) - 1:
				print(x[l])
			else:
				print(x[l], end=' ')


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count_ones = arr.count(1)
	if count_ones <= n // 2:
		ans = [0] * (n - count_ones)
		print(len(ans))
		print(*ans)
	else:
		if count_ones % 2 == 1:
			count_ones -= 1
		ans = [1] * count_ones
		print(len(ans))
		print(*ans)


def answer(n, A):
	x = sum(A)
	if x > n // 2:
		if x % 2 == 0:
			return (x, [1] * x)
		else:
			return (x - 1, [1] * (x - 1))
	else:
		return (n - x, [0] * (n - x))
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	(a, b) = answer(n, arr)
	print(a)
	print(*b)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	countzero = a.count(0)
	countone = a.count(1)
	if countone > countzero:
		if countone % 2 != 0:
			print(countone - 1)
			print('1 ' * (countone - 1))
		else:
			print(countone)
			print('1 ' * countone)
	else:
		print(countzero)
		print('0 ' * countzero)


def solve(arr):
	ones = sum(arr)
	if ones <= len(arr) // 2:
		print(len(arr) // 2)
		for i in range(len(arr) // 2 - 1):
			print('0', end=' ')
		print('0')
	else:
		if ones % 2 == 1:
			ones -= 1
		print(ones)
		for i in range(ones - 1):
			print('1', end=' ')
		print('1')
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	solve(arr)


t = int(input())
while t:
	n = int(input())
	arr = [int(i) for i in input().split()]
	b = sorted(arr)
	if b[n // 2 - 1] == 0:
		print(n // 2)
		print('0 ' * (n // 2))
	elif n % 4 == 0:
		print(n // 2)
		print('1 ' * (n // 2))
	else:
		print(n // 2 + 1)
		print('1 ' * (n // 2 + 1))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = list(input().split())
	(num_zeros, num_ones) = (arr.count('0'), arr.count('1'))
	if num_zeros == num_ones:
		print(num_zeros)
		print(' '.join(['0'] * num_zeros))
	elif num_zeros > num_ones:
		k = num_zeros
		print(k)
		print(' '.join(['0'] * k))
	else:
		k = num_ones
		if k % 2 == 1:
			k -= 1
		print(k)
		print(' '.join(['1'] * k))


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = a.count(1)
	if c <= n // 2:
		x = n - c
		count = 0
		print(x)
		for i in a:
			if i == 1 and count < x:
				count += 1
				continue
			print(i, end=' ')
		print()
	else:
		x = c // 2 * 2
		count = 0
		print(x)
		for i in a:
			if i == 1 and count < x:
				print(i, end=' ')
				count += 1
			if count == x:
				break
		print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	n1 = arr.count(1)
	n0 = n - n1
	if n1 <= n // 2:
		res = [0] * n0
		print(len(res))
		print(*res)
	else:
		if n1 % 2 == 0:
			res = [1] * n1
		else:
			res = [1] * (n1 - 1)
		print(len(res))
		print(*res)


from collections import Counter
for t in range(int(input())):
	n = int(input())
	a = input().split()
	c = Counter(a)
	if c['0'] >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	elif n // 2 % 2 == 1:
		print(n // 2 + 1)
		print('1 ' * (n // 2 + 1))
	else:
		print(n // 2)
		print('1 ' * (n // 2))


def sum(a, pos):
	s = 0
	b = a.copy()
	if pos != -1:
		b.pop(pos)
	for i in range(0, len(b)):
		if i % 2 == 0:
			s += b[i]
		else:
			s -= b[i]
	return s
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	while i < len(a):
		currsum = sum(a, -1)
		if currsum == 0:
			break
		if abs(currsum) > abs(sum(a, i)):
			a.pop(i)
		else:
			i += 1
	print(len(a))
	print(*a, sep=' ')


def count_balance(case):
	count = 0
	for j in range(0, len(case)):
		if (j + 1) % 2 == 0 and case[j] == 1:
			count = count + 1
		elif (j + 1) % 2 != 0 and case[j] == 1:
			count = count - 1
	return count

def change_balance(case, direction):
	down = 0
	up = 0
	for i in range(len(case) - 1, -1, -1):
		if (i + 1) % 2 == 0:
			if case[i] == 1:
				down = down + 1
		elif case[i] == 1:
			up = up + 1
		if down > up and direction:
			del case[i]
			break
		elif up > down and (not direction):
			del case[i]
			break
	return case

def solution(cases):
	ans = []
	for i in range(0, len(cases)):
		case = cases[i]
		count = count_balance(case)
		if count == 0:
			ans.append(case)
		else:
			for j in range(0, abs(count)):
				case = change_balance(case, count > 0)
			ans.append(case)
	return ans

def main():
	n = int(input())
	cases = []
	for i in range(0, n):
		l = int(input())
		num = list(map(int, input().split()))
		cases.append(num)
	result = solution(cases)
	for i in range(0, len(result)):
		l = len(result[i])
		print(l)
		out = ' '.join(map(str, result[i]))
		print(out)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	on = sum(a)
	k = n
	b = [1] * n
	t = 0
	if on <= n // 2:
		t = 1
	p = 0
	for (i, x) in enumerate(a):
		if x == t:
			b[i] = 0
			k -= 1
		else:
			p = i
	if k & 1 and t == 0:
		k -= 1
		b[p] = 0
	print(k)
	for (i, x) in enumerate(a):
		if b[i]:
			print(x, end=' ')
	print()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	zero = 0
	one = 0
	has = Counter(arr)
	if has[0] >= n // 2:
		print(has[0])
		ans = has[0] * '0'
		res = []
		for i in range(has[0]):
			res.append(0)
		print(*res)
	else:
		if has[1] % 2 != 0:
			has[1] -= 1
		print(has[1])
		for i in range(has[1]):
			print(1, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	p = b.count(0)
	if p >= n // 2:
		print(n // 2)
		arr = [0] * (n // 2)
		print(*arr)
	elif n % 4 == 0:
		print(n // 2)
		arr = [1] * (n // 2)
		print(*arr)
	else:
		print(n // 2 + 1)
		arr = [1] * (n // 2 + 1)
		print(*arr)


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	for i in range(n - 1, -1, -2):
		if a[i] != a[i - 1]:
			if a[i]:
				a[i] = 2
			else:
				a[i - 1] = 2
	a = [ai for ai in a if ai < 2]
	print(len(a))
	print(*a)


t = int(input())
for i in range(t):
	size = int(input())
	arr = [int(n) for n in input().split()]
	new_arr = []
	sum_o = 0
	sum_e = 0
	for j in range(0, size, 2):
		sum_o += arr[j]
		sum_e += arr[j + 1]
		new_arr.append(arr[j])
		new_arr.append(arr[j + 1])
		if sum_o < sum_e:
			new_arr.pop(-1)
			sum_e -= 1
		elif sum_o > sum_e:
			new_arr.pop(-2)
			sum_o -= 1
	print(len(new_arr))
	print(' '.join(map(str, new_arr)))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	o = arr.count(1)
	z = arr.count(0)
	if o > z:
		if (n - z) % 2 == 1:
			print(n - z - 1)
			print(*[1] * (n - z - 1))
		else:
			print(n - z)
			print(*[1] * (n - z))
	else:
		print(n - o)
		print(*[0] * (n - o))


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	c_1 = 0
	c_0 = 0
	for i in range(n):
		if li[i] == 1:
			c_1 += 1
		else:
			c_0 += 1
	if c_0 >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	else:
		par = 0 if n // 2 % 2 == 0 else 1
		if par == 0:
			print(n // 2)
			for i in range(n // 2):
				print(1, end=' ')
			print()
		else:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ')
			print()


import sys

def solve(n, a):
	ans = []
	total = sum(a)
	if total > n // 2:
		if total % 2 == 1:
			total -= 1
		for p in range(total):
			ans.append(1)
	elif total == n // 2:
		if total % 2 == 1:
			for h in range(n // 2):
				ans.append(0)
		else:
			for g in range(total):
				ans.append(1)
	else:
		if total % 2 == 1:
			total += 1
		for h in range(n - total):
			ans.append(0)
	return ans
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	a = [int(j) for j in sys.stdin.readline().split()]
	ans = solve(n, a)
	print(len(ans))
	for h in range(len(ans)):
		print(ans[h], end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	num = 0
	for i in a:
		if i == 1:
			num += 1
	if num <= n / 2:
		n = int(n / 2)
		print(n)
		for i in range(n):
			print(0, end=' ')
		print()
	elif num % 2 == 0:
		print(num)
		for i in range(num):
			print(1, end=' ')
		print()
	else:
		num = num - 1
		print(num)
		for i in range(num):
			print(1, end=' ')
		print()
	t -= 1


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
for case in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ones = sum(a)
	zeros = n - ones
	half = n // 2
	if ones == zeros:
		ans = [0] * zeros
	elif ones > zeros:
		ans = [1] * (n // 2)
		if half % 2:
			ans.append(1)
	else:
		ans = [0] * (n // 2)
		if half % 2:
			ans.append(0)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	x = int(input())
	li = list(map(int, input().split()))
	a = li.count(1)
	b = li.count(0)
	if a > b:
		print(a // 2 * 2)
		li1 = [1] * (a // 2 * 2)
	else:
		print(b)
		li1 = [0] * b
	print(*li1)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	an = []
	po = n // 2
	ar = [[], []]
	for i in range(n):
		if l[i]:
			ar[i % 2].append(i)
	if len(ar[0]) == len(ar[1]):
		print(len(l))
		print(*l)
	else:
		i = 0
		while i < n - 1:
			if l[i]:
				if l[i] == l[i + 1]:
					an.append(l[i])
					an.append(l[i + 1])
				else:
					an.append(l[i + 1])
				i += 1
			else:
				an.append(l[i])
			i += 1
		print(len(an))
		print(*an)


import math

def solve(n, a):
	if a.count(1) <= n // 2:
		return [0 for i in range(n - a.count(1))]
	elif a.count(1) % 2:
		return [1 for i in range(a.count(1) - 1)]
	else:
		return [1 for i in range(a.count(1))]
t = int(input())
for t in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	result = solve(n, a)
	print(len(result))
	print(' '.join([str(result[i]) for i in range(len(result))]))


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	ans = []
	cnt = 0
	for i in range(n):
		if a[i] == 0:
			if cnt & 1:
				cnt -= 1
			ans.extend([1] * cnt)
			ans.append(0)
			cnt = 0
		if a[i] == 1:
			cnt += 1
	if cnt & 1:
		cnt -= 1
	ans.extend([1] * cnt)
	print(len(ans))
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	c0 = 0
	c1 = 0
	for a in A:
		if a == 0:
			c0 += 1
		else:
			c1 += 1
	if c0 >= c1:
		print(n - c1)
		ans = [0] * c0
		print(*ans)
	elif c1 % 2 == 0:
		print(n - c0)
		ans = [1] * c1
		print(*ans)
	else:
		print(n - c0 - 1)
		ans = [1] * (c1 - 1)
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	ones = l.count(1)
	zeros = l.count(0)
	if ones > zeros:
		if ones % 2 == 1:
			ones -= 1
		print(ones)
		print(*[1] * ones)
	else:
		print(zeros)
		print(*[0] * zeros)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = 0
	if n == 2:
		if l[0] - l[1] != 0:
			print(1)
			print(0)
		else:
			print(2)
			print(*l)
	else:
		x = l.count(0)
		y = l.count(1)
		if x >= n // 2:
			print(n // 2)
			print(*[0 for i in range(n // 2)])
		elif n // 2 % 2 != 0:
			if y >= n // 2 + 1:
				print(n // 2 + 1)
				print(*[1 for i in range(n // 2 + 1)])
		else:
			print(n // 2)
			print(*[1 for i in range(n // 2)])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = arr.count(0)
	if x >= n // 2:
		out = [0] * x
	else:
		out = [1] * ((n - x) // 2) * 2
	print(len(out))
	print(*out)


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	c0 = 0
	c1 = 0
	for i in range(0, len(s)):
		if s[i] == 0:
			c0 += 1
		else:
			c1 += 1
	if c0 >= c1:
		L = []
		for i in range(c0):
			L.append(0)
		print(len(L))
		print(*L)
	else:
		L = []
		for i in range(c1):
			L.append(1)
		if len(L) % 2 != 0 and len(L) > 1:
			L = L[1:]
		print(len(L))
		print(*L)


for test in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	if arr.count(0) >= arr.count(1):
		ans = [0] * (n // 2)
	else:
		m = arr.count(1) // 2 * 2
		ans = [1] * m
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	cnt0 = cnt1 = 0
	value = 0
	for i in l:
		if i == 1:
			cnt1 += 1
		else:
			cnt0 += 1
	if cnt0 >= n // 2:
		value = cnt0
		ans = [0] * cnt0
	elif cnt1 % 2 == 1:
		value = cnt1 - 1
		ans = [1] * (cnt1 - 1)
	else:
		value = cnt1
		ans = [1] * cnt1
	print(value)
	print(*ans)


from collections import Counter
import string
import math

def binomialCoeff(n, k):
	if n < k:
		return 1
	C = [0 for i in range(k + 1)]
	C[0] = 1
	for i in range(1, n + 1):
		j = min(i, k)
		while j > 0:
			C[j] = C[j] + C[j - 1]
			j -= 1
	return C[k]

def array_int():
	return [int(i) for i in input().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(input())
	if number_of_variables >= 2:
		return map(int, input().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007
for _ in range(int(input())):
	n = vary(1)
	num = array_int()
	num2 = num[:]
	t = makedict(num)
	one = 0
	zero = 0
	for i in t:
		if i == 1:
			one += t[i]
		else:
			zero += t[i]
	if one <= zero:
		print(n // 2)
		print(*[0 for i in range(n // 2)])
	elif one > zero:
		if n // 2 % 2 != 0:
			print(n // 2 + 1)
			print(*[1 for i in range(n // 2 + 1)])
		else:
			print(n // 2)
			print(*[1 for i in range(n // 2)])


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	sm = 0
	k = 0
	st = 0
	ed = 0
	fd = False
	ans = []
	for i in range(n):
		if arr[i] == 1 and (not fd):
			fd = True
			st = i
		elif arr[i] == 0 and fd:
			fd = False
			if (i - st) % 2 != 0:
				st += 1
			for j in range(st, i):
				ans.append(1)
			ans.append(0)
		elif arr[i] == 0:
			ans.append(0)
	if fd:
		if (n - st) % 2 != 0:
			st += 1
		for j in range(st, n):
			ans.append(1)
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	num1 = 0
	num0 = 0
	for i in arr:
		if i == 0:
			num0 += 1
		else:
			num1 += 1
	if num0 >= num1:
		print(num0)
		for i in range(num0):
			print(0, end=' ')
		print()
	elif num1 % 2 == 0:
		print(num1)
		for i in range(num1):
			print(1, end=' ')
		print()
	else:
		print(num1 - 1)
		for i in range(num1 - 1):
			print(1, end=' ')
		print()


for tt in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	b = [n - sum(arr), sum(arr)]
	i = 1 if b[1] * 2 > n else 0
	k = b[i] - b[i] % 2 * i
	print(k)
	print(*[i] * k)


a = int(input())
for i in range(0, a):
	b = int(input())
	arr = list(map(int, input().split()))
	one = []
	zero = []
	for i in range(0, len(arr)):
		if arr[i] == 0:
			zero.append(i + 1)
		else:
			one.append(i + 1)
	if len(one) % 2 == 0:
		if len(one) < len(zero):
			print(len(zero))
			print('0 ' * len(zero))
		else:
			print(len(one))
			print('1 ' * len(one))
	elif len(one) <= len(zero):
		print(len(zero))
		print('0 ' * len(zero))
	else:
		print(len(one) - 1)
		print('1 ' * (len(one) - 1))


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 10 + 7
for _ in range(I()):
	n = I()
	a = L()
	if n // 2 % 2:
		if a.count(0) >= a.count(1):
			print(n // 2)
			print(*[0] * (n // 2))
		else:
			print(n // 2 + 1)
			print(*[1] * (n // 2 + 1))
	elif a.count(0) >= a.count(1):
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		print(n // 2)
		print(*[1] * (n // 2))


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	one = 0
	zero = 0
	for j in range(n):
		if arr[j] == 0:
			zero += 1
		else:
			one += 1
	if zero >= one:
		print(zero)
		for j in range(zero):
			print('0 ', end='')
	else:
		if one & 1:
			one -= 1
		print(one)
		for j in range(one):
			print('1 ', end='')


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	zero = a.count(0)
	one = n - zero
	if zero >= n // 2:
		print(zero)
		print('0 ' * zero)
	else:
		one -= one % 2
		print(one)
		print('1 ' * one)


for i in range(int(input())):
	length = int(input())
	l = list(map(int, input().split()))
	c_0 = l.count(0)
	if c_0 >= length // 2:
		print(c_0)
		b = list(filter(1 .__ne__, l))
		print(*b, sep=' ')
	else:
		c_1 = length - c_0
		print(c_1 - c_1 % 2)
		b = list(filter(0 .__ne__, l))
		print(*b[0:c_1 - c_1 % 2], sep=' ')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	i = 0
	while i < n - 1:
		if arr[i] == arr[i + 1]:
			res.append(arr[i])
			res.append(arr[i + 1])
		else:
			res.append(0)
		i += 2
	print(len(res))
	for i in res:
		print(i, end=' ')
	print()


import sys
for _ in range(int(input())):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	if sum(arr) <= n / 2:
		arr = [0 for i in range(n - sum(arr))]
	elif sum(arr) % 2 == 0:
		arr = [1 for i in range(sum(arr))]
	elif sum(arr) - 1 < n / 2:
		newarr = []
		for i in range(n):
			if arr[i] == 1 and len(newarr) != (n - 1) / 2:
				newarr.append(1)
			elif len(newarr) % 2 == 0 and arr[i] == 0:
				newarr.append(0)
				break
			elif arr[i] == arr[i + 1] and arr[i] == 0:
				newarr.append(0)
				newarr.append(0)
				break
			elif len(newarr) == (n - 1) / 2:
				newarr.append(0)
				break
		while sum(newarr) != (n - 1) / 2:
			newarr.append(1)
		arr = newarr
	else:
		arr = [1 for i in range(sum(arr) - 1)]
	print(len(arr))
	print(' '.join(map(str, arr)))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	check_1 = []
	for j in range(n):
		if a[j] == 1:
			check_1.append(j)
	check_rem = []
	odd = 0
	even = 0
	if len(check_1) % 2 == 1:
		check_rem.append(check_1[-1])
		check_1 = check_1[:len(check_1) - 1]
	for l in range(1, len(check_1)):
		if (check_1[l] - check_1[l - 1]) % 2 == 0 and check_1[l] - check_1[l - 1] != 0:
			check_rem.append(check_1[l] - 1)
	print(n - len(check_rem))
	for k in range(n):
		if not k in check_rem:
			print(a[k], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	zero = 0
	one = 0
	for i in arr:
		if i == 1:
			one += 1
		else:
			zero += 1
	if one <= n / 2:
		print(zero)
		arr = ['0'] * zero
		s = ' '.join(arr)
		print(s)
	elif one % 2 == 0:
		print(one)
		arr = ['1'] * one
		s = ' '.join(arr)
		print(s)
	else:
		print(str(one - 1))
		arr = ['1'] * (one - 1)
		s = ' '.join(arr)
		print(s)


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
for _ in range(int(read())):
	n = int(read())
	nums = list(readi())
	for i in range(n):
		total = 0
		step = 1
		j = 0
		while j < n:
			if j != i:
				total += step * nums[j]
				step *= -1
			j += 1
		if total == 0:
			print(n - 1)
			for x in range(n):
				if x != i:
					print(nums[x], end=' ')
			print()
			break
	else:
		print(n)
		print(' '.join(map(str, nums)))


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	num0 = 0
	num1 = 0
	for i in li:
		if i == 0:
			num0 += 1
		else:
			num1 += 1
	if num0 >= n // 2:
		print(num0)
		for i in range(num0):
			print(0, end=' ')
	else:
		if num1 % 2:
			num1 -= 1
		print(num1)
		for i in range(num1):
			print(1, end=' ')
	print()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	d = Counter(x)
	if d[1] <= n // 2:
		x = list(filter(lambda i: i != 1, x))
	else:
		x = list(filter(lambda i: i != 0, x))
		if d[1] % 2 != 0:
			x.remove(1)
	print(len(x))
	print(*x)


T = int(input())
for i in range(0, T):
	n = int(input())
	a = []
	array = [int(s) for s in input().split()]
	for j in range(0, len(array), 2):
		if array[j] == array[j + 1]:
			a.append(array[j])
			a.append(array[j + 1])
		elif array[j] > array[j + 1]:
			a.append(array[j + 1])
		else:
			a.append(array[j])
	k = len(a)
	print(k)
	for i in range(0, k):
		print(a[i], end=' ')


import sys
from collections import defaultdict
input = sys.stdin.readline
from collections import deque

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	n = inp()
	tab = inlt()
	zeros = []
	uns = []
	for j in range(n):
		if tab[j] == 0:
			zeros.append(0)
		else:
			uns.append(1)
	if len(zeros) >= len(uns):
		res = zeros
	else:
		res = uns
	if len(res) % 2 == 1 and res[0] == 1:
		del res[0]
	print(len(res))
	stri = ''
	for l in range(len(res)):
		stri = stri + str(res[l]) + ' '
	print(stri)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s1 = arr.count(1)
	s2 = arr.count(0)
	if s2 >= n // 2:
		print(s2)
		print('0 ' * s2)
	elif s1 % 2 == 1:
		print(s1 - 1)
		print('1 ' * (s1 - 1))
	else:
		print(s1)
		print('1 ' * s1)


test_case = int(input())
for i in range(test_case):
	n = int(input())
	s = input().split(' ')
	count_1 = 0
	count_0 = 0
	for j in range(n):
		if s[j] == '1':
			count_1 += 1
		else:
			count_0 += 1
	if count_0 >= n / 2:
		print(count_0)
		s = '0 ' * count_0
		print(s[:-1])
	else:
		print(count_1 // 2 * 2)
		s = '1 ' * (count_1 // 2 * 2)
		print(s[:-1])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	q0 = sum(a[::2])
	q1 = sum(a[1::2])
	if q1 == q0:
		print(n)
		for j in range(n):
			print(a[j], end=' ')
		print()
		continue
	if q1 + q0 <= int(n / 2):
		print(int(n / 2))
		for j in range(int(n / 2)):
			print(0, end=' ')
		print()
	elif int(n / 2) % 2 == 0:
		print(int(n / 2))
		for j in range(int(n / 2)):
			print(1, end=' ')
		print()
	else:
		print(int(n / 2) + 1)
		for j in range(int(n / 2) + 1):
			print(1, end=' ')
		print()


for x in range(int(input())):
	n = int(input())
	a = input()
	cnt0 = a.count('0')
	cnt1 = a.count('1')
	if cnt1 <= n // 2:
		print(cnt0, '0 ' * cnt0)
	else:
		cnt1 = cnt1 - cnt1 % 2
		print(cnt1, '1 ' * cnt1)


for _ in range(int(input())):
	n = int(input())
	A = [int(_) for _ in input().split()]
	(x, y) = (0, 0)
	for _ in range(n):
		if A[_] == 0:
			x += 1
		else:
			y += 1
	if x >= y:
		print(x)
		print(*[0 for _ in range(x)])
	elif y % 2 == 1:
		print(y - 1)
		print(*[1 for _ in range(y - 1)])
	else:
		print(y)
		print(*[1 for _ in range(y)])


for _ in range(int(input())):
	x = int(input())
	myList = list(map(int, input().split()))
	zeros = myList.count(0)
	ones = myList.count(1)
	if zeros == ones == 1 or zeros == x == 2:
		print(1)
		print(0)
	elif ones == x == 2:
		print(2)
		print(1, 1)
	elif zeros < x // 2:
		if x // 2 % 2 == 0:
			print(x // 2)
			print(*[1 for i in range(x // 2)])
		else:
			print(x // 2 + 1)
			print(*[1 for i in range(x // 2 + 1)])
	elif zeros == ones:
		if x // 2 % 2 == 0:
			print(x // 2)
			print(*[1 for i in range(x // 2)])
		else:
			z = x // 2
			print(z)
			print(*[0 for i in range(z)])
	elif x // 2 % 2 == 0:
		print(x // 2)
		print(*[0 for i in range(x // 2)])
	else:
		print(x // 2 + 1)
		print(*[0 for i in range(x // 2 + 1)])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	S = sum(a)
	if 2 * S >= n:
		if n % 4 == 0:
			print(n // 2)
			for i in range(n // 2):
				print(1, end=' ' * (i + 1 != n // 2))
		elif 2 * S == n:
			print(n // 2)
			for i in range(n // 2):
				print(0, end=' ' * (i + 1 != n // 2))
		else:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ' * (i != n // 2))
	else:
		print(n - S)
		for i in range(n - S):
			print(0, end=' ' * (i != n - S - 1))
	print()


for t in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	temp = sum(arr)
	if temp > n // 2:
		if temp % 2 == 0:
			a = [1] * temp
			print(temp)
			print(*a)
		else:
			a = [1] * (temp - 1)
			print(temp - 1)
			print(*a)
			continue
	elif temp < n // 2:
		print(n - temp)
		a = [0] * (n - temp)
		print(*a)
	else:
		print(n // 2)
		a = [0] * (n // 2)
		print(*a)


T = int(input())
for _ in range(T):
	n = int(input())
	x = list(map(int, input().split()))
	(a, b) = (0, 0)
	for i in range(len(x)):
		if x[i] == 1:
			a += 1
		else:
			b += 1
	if a > b:
		if a % 2 == 0:
			print(a)
			for i in range(a):
				print(1, end=' ')
			print()
		else:
			print(a - 1)
			for i in range(a - 1):
				print(1, end=' ')
			print()
	else:
		print(b)
		for i in range(b):
			print(0, end=' ')
		print()


def solve():
	N = int(input())
	a = list(map(int, input().split()))
	(z, o) = (a.count(0), a.count(1))
	if z >= o:
		d = N // 2
		return [0] * d
	else:
		d = N // 2
		if d % 2:
			d += 1
		return [1] * d
t = int(input())
for _ in range(t):
	ans = solve()
	print(len(ans))
	print(*ans)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	a = lin()
	(c0, c1) = (a.count(0), a.count(1))
	if c1 <= n // 2:
		print(c0)
		print(*[0] * c0)
	elif c1 % 2 != 0:
		print(c1 - 1)
		print(*[1] * (c1 - 1))
	else:
		print(c1)
		print(*[1] * c1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = arr.count(0)
	b = arr.count(1)
	if b > n // 2:
		print(b - b % 2)
		print(*[1 for _ in range(b - b % 2)])
	elif b == n // 2:
		print(a)
		print(*[0 for _ in range(a)])
	else:
		print(a - a % 2)
		print(*[0 for _ in range(a - a % 2)])


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	z = x.count(0)
	o = n - z
	if z >= n // 2:
		print(z)
		print('0 ' * z)
	else:
		print(o - o % 2)
		print('1 ' * (o - o % 2))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt1 = a.count(1)
	cnt0 = a.count(0)
	if cnt0 >= cnt1:
		print(cnt0)
		res = [0] * cnt0
		print(*res)
	elif cnt1 % 2 == 0:
		print(cnt1)
		res = [1] * cnt1
		print(*res)
	else:
		print(cnt1 - 1)
		res = [1] * (cnt1 - 1)
		print(*res)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(n0, n1) = (0, 0)
	for i in range(n):
		if l[i] == 0:
			n0 += 1
		else:
			n1 += 1
	if n0 >= n1:
		c = [0] * (n // 2)
		print(n // 2)
		print(*c)
	else:
		cur = n // 2
		c = [1] * (n // 2)
		if cur % 2 == 0:
			print(n // 2)
			print(*c)
		else:
			print(n // 2 + 1)
			c += [1]
			print(*c)


import sys
input = sys.stdin.readline
for test in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	zeros = a.count(0)
	ones = a.count(1)
	if zeros >= n // 2:
		a = [0] * zeros
	else:
		a = [1] * (2 * (ones // 2))
	print(len(a))
	print(*a)


def count(a, i):
	c = 1
	while i < len(a) - 1:
		if not a[i + 1]:
			c += 1
			i += 1
		else:
			return c
	return 0
for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	if sum(a) % 2:
		a.remove(1)
	left = 0
	right = 0
	for i in range(len(a)):
		if i % 2:
			left += a[i]
		else:
			right += a[i]
	if left != right:
		for i in range(1, len(a)):
			if len(a) > i:
				if not a[i] and a[i - 1]:
					c = count(a, i)
					if c % 2:
						a.pop(i)
	print(len(a))
	for el in a:
		print(el, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ones = 0
	for i in range(n):
		if a[i] == 1:
			ones += 1
	if ones > n // 2:
		if ones % 2 == 0:
			lst = [1 for x in range(ones)]
			print(len(lst))
			print(*lst)
		else:
			lst = [1 for x in range(ones - 1)]
			print(len(lst))
			print(*lst)
	else:
		lst = [0 for x in range(n // 2)]
		print(len(lst))
		print(*lst)


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	while i < n:
		if a[i] == 1:
			nexti = None
			for j in range(i + 1, n):
				if a[j] == 1:
					nexti = j
					break
			if nexti is None:
				del a[i]
				n -= 1
				i = n
			elif (nexti - i) % 2 == 0:
				del a[i + 1]
				i = nexti
				n -= 1
			else:
				i = nexti + 1
		else:
			i += 1
	print(n)
	print(' '.join(map(str, a)))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c0 = arr.count(0)
	c1 = arr.count(1)
	if c0 < c1:
		if (n - min(c0, c1)) % 2:
			l = n - min(c0, c1) - 1
			arr = [1] * (n - min(c0, c1) - 1)
		else:
			l = n - min(c0, c1)
			arr = [1] * (n - min(c0, c1))
	else:
		arr = [0] * (n - min(c0, c1))
		l = n - min(c0, c1)
	print(l)
	print(*arr, sep=' ')


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	tt = I()
	for ii in range(tt):
		n = I()
		l = IL()
		ev = 0
		for ll in l:
			if ll == 0:
				ev += 1
		res = None
		ans = None
		if ev >= n // 2:
			res = ev
			ans = 0
		else:
			res = n - ev
			ans = 1
		if res == n // 2 and res % 2 == 1 and (ans == 1):
			print(n // 2)
			for p in range(n // 2):
				print(0, end=' ')
			print()
		else:
			if res % 2 == 1 and res != n // 2:
				res -= 1
			print(res)
			for i in range(res):
				print(ans, end=' ')
			print()
			pass
solve()


for t in range(int(input())):
	n = int(input())
	(even0, even1) = ([], [])
	(odd0, odd1) = ([], [])
	a = list(map(int, input().split()))
	while True:
		last_eq = -1
		total = 0
		for i in range(len(a)):
			if i % 2:
				s = -1
			else:
				s = 1
			if a[i] == 1:
				total += s
			if not total:
				last_eq = i
		if total == 0:
			print(len(a))
			print(*a)
			break
		elif total > 0:
			find = (total + 1) // 2
			total = 0
			for i in range(last_eq + 1, len(a)):
				if i % 2:
					s = -1
				else:
					s = 1
				if a[i] == 1:
					total += s
				if total == find:
					del a[i]
					break
		elif total < 0:
			find = total // 2
			total = 0
			for i in range(last_eq + 1, len(a)):
				if i % 2:
					s = -1
				else:
					s = 1
				if a[i] == 1:
					total += s
				if total == find:
					del a[i]
					break


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count_1 = a.count(1)
	if count_1 <= n / 2:
		a_ = [num for num in a if num == 0]
	else:
		a_ = [num for num in a if num == 1]
		if len(a_) % 2 != 0:
			del a_[0]
	print(len(a_))
	print(*a_)


def print_ans(N, lst):
	cnt0 = lst.count('0')
	cnt1 = lst.count('1')
	if cnt1 <= N // 2:
		print(N // 2)
		for _ in range(N // 2):
			print('0', end=' ')
	else:
		cnt = cnt1 if cnt1 % 2 == 0 else cnt1 - 1
		print(cnt)
		for _ in range(cnt):
			print('1', end=' ')
T = int(input())
for _ in range(T):
	N = int(input())
	lst = input().split(' ')
	print_ans(N, lst)
	print()


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split() if i != '\n']
	if sum(a) > n / 2:
		ans = [1] * sum(a)
		if len(ans) & 1:
			ans.pop()
	else:
		ans = [0] * int(n / 2)
	print(len(ans))
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s0 = a.count(0)
	s1 = a.count(1)
	if s0 >= s1:
		print(n // 2)
		for j in range(n // 2):
			print('0', end=' ')
	else:
		if n // 2 % 2 != 0:
			n = n + 2
		print(n // 2)
		for j in range(n // 2):
			print('1', end=' ')
	print('')


t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	(c0, c1) = (0, 0)
	for i in l:
		if i:
			c1 -= -1
		else:
			c0 -= -1
	if c1 > c0:
		if c1 % 2:
			c1 += -1
		print(c1, '1 ' * c1, sep='\n')
	else:
		print(c0, '0 ' * c0, sep='\n')


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	s0 = 0
	s1 = 0
	for x in a:
		if x == 0:
			s0 += 1
		else:
			s1 += 1
	b = []
	if s1 <= n // 2:
		for x in a:
			if x != 1:
				b.append(x)
	elif s0 < n // 2:
		for x in a:
			if x != 0:
				b.append(x)
		if len(b) % 2 != 0:
			del b[0]
	else:
		b = a
	print(len(b))
	for x in b:
		print(x, end=' ')
	print()
	t -= 1


for ad in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if l.count(1) <= n // 2:
		x = l.count(0)
		ans = '0' * x
	elif n % 4 == 0:
		x = n // 2
		ans = '1' * (n // 2)
	else:
		x = n // 2 + 1
		ans = '1' * (n // 2 + 1)
	print(x)
	ans = list(ans)
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	z = 0
	o = 0
	k = []
	for i in a:
		if i == 0:
			z += 1
		else:
			o += 1
	if o <= n // 2 and o <= z:
		for i in a:
			if i == 0:
				k.append(i)
	elif z <= n // 2 and z < o:
		for i in a:
			if i == 1:
				k.append(i)
		if len(k) % 2 != 0 and len(k) > 1:
			k.remove(k[len(k) - 1])
	print(len(k))
	for i in k:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	for i in a:
		if i == 1:
			c += 1
	if n == 2:
		if c == 2:
			print(2)
			print(1, 1)
		elif c == 1:
			print(1)
			print(0)
		else:
			print(2)
			print(0, 0)
	elif c == n or c == 0:
		print(n)
		for i in a:
			print(i, end=' ')
		print()
	elif c == n // 2 and c % 2 == 1:
		ans = [0] * (n // 2)
		print(n // 2)
		for i in ans:
			print(i, end=' ')
		print()
	elif c >= n // 2:
		temp = c if c % 2 == 0 else c - 1
		print(temp)
		for i in range(temp):
			print(1, end=' ')
		print()
	else:
		ans = [0] * (n // 2)
		print(n // 2)
		for i in ans:
			print(i, end=' ')
		print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	one = zero = 0
	for e in a:
		if e == 1:
			one += 1
		else:
			zero += 1
	if one > zero:
		if one % 2 == 1:
			print(n - zero - 1)
			print('1 ' * (n - zero - 1))
		else:
			print(n - zero)
			print('1 ' * (n - zero))
	else:
		print(n - one)
		print('0 ' * (n - one))


from math import ceil
from collections import deque, defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	i = 0
	if n == 2:
		if a[0] - a[1] == 0:
			print(2)
			print(a[0], a[1])
		else:
			print(1)
			print(0)
	else:
		while i <= n - 2:
			if a[i] - a[i + 1] == 0:
				l.append(a[i])
				l.append(a[i + 1])
				i += 2
			elif i <= n - 3 and a[i] - a[i + 2] == 0:
				l.append(a[i])
				l.append(a[i + 2])
				i += 3
			elif i <= n - 3:
				l.append(a[i + 1])
				l.append(a[i + 2])
				i += 3
			else:
				i += 1
		print(len(l))
		for i in range(len(l)):
			print(l[i], end=' ')
		print()


from __future__ import division, print_function
import os, sys
import math
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def sli():
	return list(msi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def factorial(n):
	return 1 if n == 1 or n == 0 else n * factorial(n - 1)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		if a.count(0) >= a.count(1):
			print(a.count(0))
			for i in range(a.count(0)):
				print(0, end=' ')
			print()
		elif a.count(1) % 2:
			print(a.count(1) - 1)
			for i in range(a.count(1) - 1):
				print(1, end=' ')
			print()
		else:
			print(a.count(1))
			for i in range(a.count(1)):
				print(1, end=' ')
			print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, os.path
import math
from collections import Counter
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve(l, n):
	x = Counter(l)
	if x[0] >= x[1]:
		print(x[0])
		print(' '.join('0' * x[0]))
	elif x[1] % 2 == 0:
		print(x[1])
		print(' '.join('1' * x[1]))
	else:
		print(x[1] - 1)
		print(' '.join('1' * (x[1] - 1)))
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	solve(l, n)


for _ in range(int(input())):
	n = int(input())
	s = input().split()
	l = [0, 0]
	for i in range(n):
		if int(s[i]):
			l[0] = l[0] + int(s[i])
		else:
			l[1] = l[1] + int(s[i])
	if l[0] > n // 2:
		if l[0] % 2 != 0:
			l[0] = l[0] - 1
		print(l[0])
		print(*l[0] * '1')
	else:
		print(n - l[0])
		print(*'0' * (n - l[0]))


N = int(input())
for i in range(N):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for j in range(len(a) // 2):
		x = a[2 * j]
		y = a[2 * j + 1]
		if x == y:
			b.append(x)
			b.append(y)
		else:
			b.append(0)
	print(len(b))
	print(*b)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	if sum(a) <= n // 2:
		print(n // 2)
		print(' '.join(['0' for _ in range(n // 2)]))
	elif n % 4 == 0:
		print(n // 2)
		print(' '.join(['1' for _ in range(n // 2)]))
	else:
		print(n // 2 + 1)
		print(' '.join(['1' for _ in range(n // 2 + 1)]))


try:
	t = int(input())
	while t != 0:
		n = int(input())
		arr = list(map(int, input().split()))
		popi = []
		count = 1
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				count += 1
			else:
				popi.append([arr[i], count])
				count = 1
		popi.append([arr[n - 1], count])
		result = []
		for i in range(len(popi)):
			if popi[i][0] == 0:
				result += [0] * popi[i][1]
			elif popi[i][1] % 2 == 0:
				result += [1] * popi[i][1]
			elif popi[i][1] > 1:
				result += [1] * (popi[i][1] - 1)
		print(len(result))
		print(*result)
		t = t - 1
except EOFError:
	print(' ')


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	poss = []
	(i, j) = (0, 0)
	if l.count(1) == l.count(0):
		ans = []
		for i in l:
			if i == 0:
				ans.append(i)
		print(len(l) - len(ans))
		print(*ans)
	elif l.count(1) > l.count(0):
		ans = []
		for i in l:
			if i == 1:
				ans.append(i)
		if len(ans) % 2 != 0:
			ans.pop()
			print(len(ans))
			print(*ans)
		else:
			print(len(ans))
			print(*ans)
	else:
		ans = []
		for i in l:
			if i == 0:
				ans.append(i)
		if len(ans) % 2 != 0:
			ans.pop()
			print(len(ans))
			print(*ans)
		else:
			print(len(ans))
			print(*ans)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	c = 0
	for i in range(n):
		if ar[i] == 1:
			c += 1
	if c <= n // 2:
		print(n - c)
		print(*[0 for i in range(n - c)])
	elif c % 2:
		print(c - 1)
		print(*[1 for i in range(c - 1)])
	else:
		print(c)
		print(*[1 for i in range(c)])


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = a.count(0)
	if l >= n // 2:
		print(l)
		print('0 ' * l)
	else:
		y = n - l
		if y % 2 == 0:
			print(y)
			print('1 ' * y)
		else:
			print(y - 1)
			print('1 ' * (y - 1))


for _ in range(int(input())):
	(n, m) = (int(input()), list(map(int, input().strip().split())))
	p = []
	for x in range(0, n, 2):
		if m[x] != m[x + 1]:
			p.append(0)
		else:
			p.append(m[x])
			p.append(m[x + 1])
	print(len(p))
	print(*p)


import math

def get_int():
	return int(input())

def get_int_list():
	return list(map(int, input().split()))

def get_char_list():
	return list(input())
cases = get_int()
for _ in range(cases):
	n = get_int()
	ints = get_int_list()
	i = 1
	target = []
	while i < n:
		if ints[i] == ints[i - 1]:
			target.append(ints[i])
			target.append(ints[i])
			i += 2
		elif i + 1 < n:
			target.append(ints[i + 1])
			target.append(ints[i + 1])
			i += 3
		else:
			break
	tn = len(target)
	if tn == 0:
		print(1)
		print(0)
	else:
		print(tn)
		print(*target)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = sum(a[::2]) - sum(a[1::2])
	if d == 0:
		print(n)
		print(*a)
	else:
		zero = 0
		for aa in a:
			if aa == 0:
				zero += 1
		if zero * 2 >= n:
			print(zero)
			b = [0] * zero
			print(*b)
		elif zero % 2 == 0:
			b = []
			for aa in a:
				if aa == 1:
					b.append(aa)
			print(len(b))
			print(*b)
		else:
			b = []
			for aa in a:
				if aa == 1:
					b.append(aa)
			b = b[1:]
			print(len(b))
			print(*b)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == 1 and arr[0] == 1:
		print(0)
		print([])
		t = t - 1
		continue
	s = sum(arr)
	if s % 2 != 0:
		for i in range(len(arr)):
			if arr[i] == 1:
				arr.pop(i)
				break
	res = []
	(start, end) = (-1, -1)
	rem = []
	for i in range(len(arr)):
		if arr[i] == 1 and start == -1:
			start = i
			continue
		if arr[i] == 1 and end == -1:
			end = i
			if (end - start) % 2 == 0 and end - start != 1:
				rem.append(end - 1)
			start = -1
			end = -1
	for i in range(len(arr)):
		if i not in rem:
			res.append(arr[i])
	print(len(res))
	for i in res:
		print(i, end=' ')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(count, cnt) = (a.count(1), a.count(0))
	if count == cnt:
		print(n // 2)
		lst = [0] * (n // 2)
		print(*lst, sep=' ')
	elif count > cnt:
		if count % 2 == 0:
			lst = [1] * count
			print(len(lst))
			print(*lst, sep=' ')
		else:
			lst = [1] * (count - 1)
			print(len(lst))
			print(*lst, sep=' ')
	elif cnt % 2 == 0:
		lst = [0] * cnt
		print(len(lst))
		print(*lst, sep=' ')
	else:
		lst = [0] * (cnt - 1)
		print(len(lst))
		print(*lst, sep=' ')


a = int(input())
for x in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	if c.count(0) == 0:
		print(b)
		print(*c)
	elif c.count(0) >= int(b / 2):
		print(int(b / 2))
		for x in range(int(b / 2)):
			print(0, end=' ')
		print()
	elif b == 2:
		if c.count(0) == 1:
			print(1)
			print(0)
		else:
			print(2)
			print(*c)
	else:
		h = []
		s = 0
		p = 0
		t = 0
		if c.count(1) % 2 == 0:
			print(c.count(1))
			for y in range(c.count(1)):
				print(1, end=' ')
			print()
		else:
			print(c.count(1) - 1)
			for y in range(c.count(1) - 1):
				print(1, end=' ')
			print()


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
ans = 0

def pr_list(a):
	print(*a, sep=' ')

def swap(a, b):
	temp = a
	a = b
	b = temp
	return [a, b]

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		n = inp()
		a = inlt()
		ans = []
		ones = 0
		for i in range(n):
			if a[i] == 0:
				if ones % 2 == 1:
					ans.pop()
				ones = 0
				ans.append(0)
			else:
				ans.append(1)
				ones = ones + 1
		if ones % 2 == 1:
			ans.pop()
		print(len(ans))
		pr_list(ans)
main()


for _ in range(int(input())):
	N = int(input())
	tart = N >> 1
	List = [int(x) for x in input().split()]
	Zero = List.count(0)
	One = List.count(1)
	if tart & 1:
		if Zero >= tart:
			print(tart)
			print(*[0] * tart)
		else:
			print(tart + 1)
			print(*[1] * (tart + 1))
	elif Zero >= tart:
		print(tart)
		print(*[0] * tart)
	else:
		print(tart)
		print(*[1] * tart)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	s = data()
	if s.count('0') >= n // 2:
		out(n // 2)
		outa(*['0'] * (n // 2))
		continue
	if n // 2 & 1:
		if s.count('1') > n // 2:
			out(n // 2 + 1)
			outa(*['1'] * (n // 2 + 1))
			continue
	out(n // 2)
	outa(*['1'] * (n // 2))


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	n = inn()
	a = arr()
	if len(set(a)) == 1:
		print(n)
		print(*a)
	elif a.count(0) >= n // 2:
		ans = [0] * (n // 2)
		print(n // 2)
		print(*ans)
	else:
		res = n // 2
		if res % 2 == 0:
			ans = [1] * (n // 2)
		else:
			ans = [1] * (n // 2 + 1)
		print(len(ans))
		print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = map(int, input().split())
	out = []
	for _ in range(n // 2):
		if next(l) + next(l) == 2:
			out.append(1)
			out.append(1)
		else:
			out.append(0)
	print(len(out))
	print(' '.join(map(str, out)))


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	x = a.count(0)
	y = N - x
	if x >= N // 2:
		print(x)
		print(*[0] * x)
	elif y % 2:
		print(y - y % 2)
		print(*[1] * (y - y % 2))
	else:
		print(y)
		print(*[1] * y)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	zero = a.count(0)
	one = n - zero
	if one > zero:
		one = 2 * (one // 2)
		print(one)
		for x in range(one):
			print('1', end=' ')
	else:
		print(zero)
		for x in range(zero):
			print('0', end=' ')
	print()
	t -= 1


t = int(input())
while t > 0:
	n = int(input())
	lst = list(map(int, input().split()))
	count = lst.count(0)
	if count >= n // 2:
		ans = [0] * (n // 2)
		print(n // 2)
		print(*ans)
	else:
		count1 = lst.count(1)
		if count1 % 2 == 0:
			print(count1)
			ans = [1] * count1
			print(*ans)
		elif count1 - 1 >= n // 2:
			print(count1 - 1)
			ans = [1] * (count1 - 1)
			print(*ans)
		else:
			print(count1)
			ans = [1] * (count1 - 1) + [0]
			print(*ans)
	t -= 1


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	p = n // 2
	l2 = []
	if p % 2:
		if a[0] != a[1]:
			l2.append(0)
		else:
			l2.append(a[0])
			l2.append(a[1])
		for i in range(2, n, 4):
			sum = a[i] - a[i + 1] + a[i + 2] - a[i + 3]
			count = a[i] + a[i + 1] + a[i + 2] + a[i + 3]
			if sum == 0:
				l2.append(a[i])
				l2.append(a[i + 1])
				l2.append(a[i + 2])
				l2.append(a[i + 3])
			elif count >= 2:
				l2.append(1)
				l2.append(1)
			else:
				l2.append(0)
				l2.append(0)
	else:
		for i in range(0, n, 4):
			sum = a[i] - a[i + 1] + a[i + 2] - a[i + 3]
			count = a[i] + a[i + 1] + a[i + 2] + a[i + 3]
			if sum == 0:
				l2.append(a[i])
				l2.append(a[i + 1])
				l2.append(a[i + 2])
				l2.append(a[i + 3])
			elif count >= 2:
				l2.append(1)
				l2.append(1)
			else:
				l2.append(0)
				l2.append(0)
	print(len(l2))
	print(*l2)
	t = t - 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	i = 0
	while True:
		if len(arr[2 * i:]) == 0:
			break
		if len(arr[2 * i:]) == 1:
			if arr[2 * i] == 1:
				arr = arr[:2 * i]
			break
		elif len(arr[2 * i:]) == 2:
			if sum(arr[2 * i:]) == 1:
				if arr[2 * i] == 1:
					arr = arr[:2 * i] + arr[2 * i + 1:]
				elif arr[2 * i + 1] == 1:
					arr = arr[:2 * i + 1]
			break
		if arr[2 * i] != arr[2 * i + 1]:
			if arr[2 * i + 2] == arr[2 * i]:
				arr = arr[:2 * i + 1] + arr[2 * i + 2:]
			else:
				arr = arr[:2 * i] + arr[2 * i + 1:]
		i += 1
	print(len(arr))
	print(*arr)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	n = int(inp())
	arr = lmp()
	z = arr.count(0)
	o = arr.count(1)
	if z >= o:
		print(z)
		print(*[0 for i in range(z)])
	else:
		o = 2 * (o // 2)
		print(o)
		print(*[1 for i in range(o)])


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s0 = arr.count(0)
	s1 = arr.count(1)
	if s1 <= n // 2:
		arr = [i for i in arr if i != 1]
	else:
		arr = [i for i in arr if i != 0]
		if s1 % 2 != 0:
			arr.remove(1)
	print(len(arr))
	for i in arr:
		print(i, end=' ')
	print('\n')


for T in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	z = l.count(1)
	if z <= n // 2:
		print(n - z)
		print('0 ' * (n - z))
	elif z > n // 2:
		if z % 2 == 0:
			print(z)
			print('1 ' * z)
		else:
			print(z - 1)
			print('1 ' * (z - 1))


def op():
	n = int(input())
	arr = list(map(int, input().split()))
	one = arr.count(1)
	zero = n - one
	if zero >= n // 2:
		print(zero)
		for i in range(zero):
			print('0 ', end='')
	else:
		print(one - one % 2)
		for i in range(one - one % 2):
			print('1 ', end='')
t = int(input())
while t > 0:
	t = t - 1
	op()
	print()


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
import random
import sys
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	a = 0
	b = 0
	for i in range(n):
		if A[i] == 0:
			a += 1
		else:
			b += 1
	if a >= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	elif n // 2 % 2 == 0:
		print(n // 2)
		print('1 ' * (n // 2))
	elif b % 2 == 0:
		print(b)
		print('1 ' * b)
	else:
		print(b - 1)
		print('1 ' * (b - 1))


for _ in range(int(input())):
	n = int(input()) // 2
	l = list(map(str, input().split()))
	if l.count('1') > l.count('0'):
		out = '1 '
	else:
		out = '0 '
	if n % 2 == 1 and out == '1 ':
		n = n + 1
	print(n)
	print(out * n)


for query in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if sum(a) <= n // 2:
		print(n // 2)
		for x in range(n // 2):
			print(0, end=' ')
	else:
		print(n // 2 + int(n // 2 % 2 == 1))
		for x in range(n // 2):
			print(1, end=' ')
		if n // 2 % 2 == 1:
			print(1, end=' ')
	print(' ')


a = int(input())
for i in range(a):
	b = int(input())
	c = [int(x) for x in input().split()]
	count = c[0]
	count1 = 0
	for j in range(b):
		if c[j] == count:
			count1 = count1 + 1
		if c[j] != count:
			if count == 1:
				if count1 % 2 != 0:
					c[j - 1] = 10 ** 4
			count1 = 1
			count = c[j]
	if count == 1:
		if count1 % 2 != 0:
			c[b - 1] = 10 ** 4
	d = []
	for j in range(b):
		if c[j] != 10 ** 4:
			d.append(c[j])
	print(len(d))
	for j in range(len(d)):
		print(d[j], end=' ')
	print()


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from collections import Counter
for __ in range(itg()):
	n = itg()
	arr = tuple(mpint())
	counter = Counter(arr)
	k = n >> 1
	if n == 2:
		if counter[0] == 1:
			ans = [0]
		else:
			k = 2
			ans = arr
	elif n % 4 == 0:
		if counter[0] > k:
			ans = [0] * k
		else:
			ans = [1] * k
	else:
		k += 1
		counter2 = Counter(arr[:3])
		counter -= counter2
		if counter2[0] >= 2:
			ans = [0] * 2
		else:
			ans = [1] * 2
		if counter[0] > counter[1]:
			ans += [0] * (k - 2)
		else:
			ans += [1] * (k - 2)
	print(k)
	print(*ans)


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		nums = [int(x) for x in input().split()]
		cnt0 = nums.count(0)
		cnt1 = nums.count(1)
		if cnt1 <= n // 2:
			for k in range(cnt1):
				nums.remove(1)
		else:
			for k in range(cnt0):
				nums.remove(0)
			if cnt1 % 2 == 1:
				nums.remove(1)
		print(len(nums))
		for num in nums:
			print(num, end=' ')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	ones = a.count('1')
	if ones <= n // 2:
		print(n - ones)
		print(' '.join(['0'] * (n - ones)))
	else:
		zz = ones // 2 * 2
		print(zz)
		print(' '.join(['1'] * zz))


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	cnt1 = a.count('1')
	cnt0 = n - cnt1
	if cnt0 >= cnt1:
		print(cnt0)
		print(('0 ' * cnt0).strip())
	elif cnt1 % 2 == 0:
		print(cnt1)
		print(('1 ' * cnt1).strip())
	else:
		print(cnt1 - 1)
		print(('1 ' * (cnt1 - 1)).strip())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	sum_arr = sum([arr[i] for i in range(0, n, 2)]) - sum([arr[i] for i in range(1, n, 2)])
	res = []
	one_cnt = arr.count(1)
	if sum_arr == 0:
		res = arr
	elif one_cnt <= n // 2:
		res = [0 for i in range(n - one_cnt)]
	elif one_cnt % 2 == 0:
		res = [1 for i in range(one_cnt)]
	else:
		res = [1 for i in range(one_cnt - 1)]
	print(len(res))
	print(' '.join(map(str, res)))


ans = []
for x in range(int(input())):
	res = []
	waste = int(input())
	l = list(map(int, input().split()))
	a = l.count(1)
	b = l.count(0)
	if a > b:
		if a % 2 == 0:
			for y in range(a):
				c = 1
				dd = str(c)
				res.append(dd)
			sep = ' '
			de = sep.join(res)
			ans.append(len(res))
			ans.append(de)
		else:
			d = a - 1
			for y in range(d):
				c = 1
				dd = str(c)
				res.append(dd)
			sep = ' '
			de = sep.join(res)
			ans.append(len(res))
			ans.append(de)
	elif a == b:
		for y in range(a):
			c = 0
			dd = str(c)
			res.append(dd)
		sep = ' '
		de = sep.join(res)
		ans.append(len(res))
		ans.append(de)
	elif b > a:
		for y in range(b):
			c = 0
			dd = str(c)
			res.append(dd)
		sep = ' '
		de = sep.join(res)
		ans.append(len(res))
		ans.append(de)
for x1 in ans:
	print(x1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(1) <= n // 2:
		final = [0] * (n // 2)
		print(len(final))
		print(*final)
	else:
		final = [1] * (a.count(1) // 2 * 2)
		print(len(final))
		print(*final)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = l.count(1)
	y = l.count(0)
	if x <= y:
		print(y)
		for j in range(y):
			print('0', end=' ')
		print()
	else:
		x = x if x % 2 == 0 else x - 1
		print(x)
		for j in range(x):
			print('1', end=' ')
		print()


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = [0, 0]
	for j in range(n):
		B[A[j]] += 1
	if B[1] <= n // 2:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		m = n // 2 if n // 2 % 2 == 0 else n // 2 + 1
		print(m)
		print(*[1] * m)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	a = arr.count(0)
	b = arr.count(1)
	if a >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	else:
		if n // 2 % 2 == 0:
			k = n // 2
		else:
			k = n // 2 + 1
		print(k)
		for i in range(k):
			print(1, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	A = sum(map(int, input().split()))
	if A <= n // 2:
		print(n // 2)
		print(' '.join(['0' for i in range(n // 2)]))
	elif n % 4 == 0:
		print(n // 2)
		print(' '.join(['1' for i in range(n // 2)]))
	else:
		print(n // 2 + 1)
		print(' '.join(['1' for i in range(n // 2 + 1)]))


import sys
from sys import stdin, stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
try:
	for _ in range(int(input())):
		n = int(input())
		arr = [int(i) for i in input().split()]
		(cz, co) = (arr.count(0), arr.count(1))
		if cz >= n // 2:
			print(n // 2)
			for i in range(n // 2):
				print(0, end=' ')
		elif co >= n // 2:
			if n // 2 & 1:
				print(n // 2 + 1)
				for i in range(n // 2 + 1):
					print(1, end=' ')
			else:
				print(n // 2)
				for i in range(n // 2):
					print(1, end=' ')
		print()
except EOFError as e:
	print(e)


import sys
import math
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	one = 0
	zer = 0
	for j in a:
		if j == 1:
			one += 1
		else:
			zer += 1
	if one <= n // 2:
		print(zer)
		for j in range(zer):
			print(0, end=' ')
	else:
		if zer % 2 == 1 and n != 2:
			one -= 1
		print(one)
		for j in range(one):
			print(1, end=' ')
	print('')


t = int(input())
for i in range(0, t):
	m = int(input())
	arr = list(map(int, input().strip().split()))
	zc = arr.count(0)
	oc = arr.count(1)
	l1 = []
	if zc >= oc:
		for j in range(0, zc):
			l1.append(0)
	elif oc % 2 == 0:
		for j in range(0, oc):
			l1.append(1)
	else:
		for j in range(0, oc - 1):
			l1.append(1)
	y = len(l1)
	print(y)
	print(*l1, sep=' ')


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	o = a.count(1)
	z = n - o
	if o == n:
		print(n)
		print(*[1] * n)
	elif z == n:
		print(n)
		print(*[0] * n)
	elif z >= n // 2:
		print(z)
		print(*[0] * z)
	elif o >= n // 2 and o % 2 == 0:
		print(o)
		print(*[1] * o)
	else:
		print(o - 1)
		print(*[1] * (o - 1))


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		(one, zero) = ([], [])
		for x in a:
			if x == 1:
				one.append(x)
			else:
				zero.append(x)
		m = n // 2
		if m % 2 == 0:
			print(n // 2)
			if len(one) > n // 2:
				print(' '.join([str(1)] * (n // 2)))
			else:
				print(' '.join([str(0)] * (n // 2)))
		elif len(one) > n // 2:
			if len(one) % 2 == 1:
				print(len(one) - 1)
				print(' '.join([str(1)] * (len(one) - 1)))
			else:
				print(len(one))
				print(' '.join([str(1)] * len(one)))
		else:
			print(n // 2)
			print(' '.join([str(0)] * (n // 2)))
main()


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	(o, z) = (0, 0)
	for i in range(n):
		if a[i]:
			o += 1
		else:
			z += 1
	if o <= n // 2:
		print(z)
		print('0 ' * z)
	else:
		o -= o % 2
		print(o)
		print('1 ' * o)


t = int(input(''))
arr = []
for i in range(t):
	n = int(input(''))
	arr.append(list(map(int, input().split())))
for i in arr:
	n = len(i)
	cnt0 = i.count(0)
	cnt1 = i.count(1)
	if cnt0 >= cnt1:
		print(cnt0)
		sol = [0] * cnt0
		print(*sol)
	else:
		c = cnt1
		if c % 2 == 0:
			print(c)
			sol = [1] * c
			print(*sol)
		else:
			print(c - 1)
			sol = [1] * (c - 1)
			print(*sol)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	a = 0
	b = 0
	for j in range(n):
		if arr[j] == 0:
			a += 1
		else:
			b += 1
	if a >= b:
		print(n // 2)
		ans = [0] * (n // 2)
		print(' '.join((str(x) for x in ans)))
	elif n // 2 % 2 == 0:
		print(n // 2)
		ans = [1] * (n // 2)
		print(' '.join((str(x) for x in ans)))
	else:
		c = n // 2 + 1
		print(c)
		ans = [1] * c
		print(' '.join((str(x) for x in ans)))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		cnt = [0, 0]
		for i in a:
			cnt[i] += 1
		if cnt[0] >= cnt[1]:
			l = [0] * (n // 2)
		elif n // 2 % 2 == 0:
			l = [1] * (n // 2)
		else:
			l = [1] * (n // 2 + 1)
		print(len(l))
		print(*l)
main()


from collections import Counter
import math
t = int(input())
for some_num in range(t):
	n = int(input())
	k = [int(i) for i in input().split(' ')]
	kc = Counter(k)
	if kc[0] >= n / 2:
		print(kc[0])
		print('0 ' * kc[0])
	else:
		a = kc[1] // 2 * 2
		print(a)
		print('1 ' * a)


def main():
	t = int(input())
	for case in range(t):
		n = int(input())
		ar = [int(x) for x in input().split()]
		i_start = -1
		lis = []
		for i in range(n):
			if ar[i] == 1:
				if i_start == -1:
					i_start = i
				elif (i - i_start) % 2 == 0:
					lis.append(i_start)
					i_start = i
				else:
					i_start = -1
			if i == n - 1 and i_start != -1:
				lis.append(i_start)
		count = 0
		for i in range(len(lis)):
			ar.pop(lis[i] - count)
			count += 1
		print(len(ar))
		print(*ar)
main()


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	zero = a.count(0)
	ones = a.count(1)
	if zero < ones:
		ans = []
		for i in a:
			if i == 1:
				ans.append(i)
		if ones % 2:
			ans.pop()
		print(len(ans))
		print(*ans)
	else:
		print(zero)
		print(*[0] * zero)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ans = []
	flag = 0
	cou = 0
	for i in range(n):
		if ar[i] == 1 and flag:
			if cou & 1:
				ans = ans + [1] + [0] * (cou - 1) + [1]
			else:
				ans = ans + [1] + [0] * cou + [1]
			flag = 0
			cou = 0
		elif ar[i] == 1:
			flag = 1
			ans += [0] * cou
			cou = 0
		elif ar[i] == 0:
			cou += 1
	if cou != 0:
		ans += [0] * cou
	print(len(ans))
	s = ''
	for i in ans:
		s += str(i) + ' '
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	s0 = l1.count(0)
	s1 = l1.count(1)
	if s0 % 2 == 0 and s1 % 2 == 0:
		m = max(s0, s1)
		print(m)
		if m == s0:
			for i in range(m - 1):
				print(0, end=' ')
			print(0)
		else:
			for i in range(m - 1):
				print(1, end=' ')
			print(1)
	elif s0 % 2 != 0 and s1 % 2 != 0:
		if s0 == s1:
			print(s0)
			for i in range(s0 - 1):
				print(0, end=' ')
			print(0)
		else:
			m = max(s0, s1)
			print(m - 1)
			if m == s0:
				for i in range(m - 2):
					print(0, end=' ')
				print(0)
			else:
				for i in range(m - 2):
					print(1, end=' ')
				print(1)


for _ in range(int(input())):
	n = int(input())
	(o, z) = (0, 0)
	for i in input().split():
		t = int(i)
		if t == 0:
			z += 1
		if t == 1:
			o += 1
	ans = [0] * z if z >= o else [1] * o
	if ans[0] == 1 and len(ans) % 2 == 1:
		ans.pop()
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = l.count(1)
	z = l.count(0)
	e = n // 2
	if o == 0:
		print(n)
		print(*l)
		continue
	if o <= e:
		print(n - o)
		m = [0] * (n - o)
		print(*m)
		continue
	if o % 2 == 0 and z <= e:
		print(o)
		m = [1] * (n - z)
		print(*m)
		continue
	if o % 2 == 1 and z <= e:
		print(o - 1)
		m = [1] * (n - z - 1)
		print(*m)
		continue


t = int(input())
for z in range(t):
	n = int(input())
	arr = [int(inp) for inp in input().split()]
	cnt1 = cnt0 = 0
	for num in arr:
		if num == 1:
			cnt1 += 1
		else:
			cnt0 += 1
	ans = ''
	if cnt1 <= n / 2:
		for x in range(cnt0):
			ans += '0 '
		ans = str(cnt0) + '\n' + ans
		print(ans)
		continue
	if cnt1 % 2 == 0:
		ans = str(cnt1) + '\n' + ans
		for x in range(cnt1):
			ans += '1 '
	else:
		ans = str(cnt1 - 1) + '\n' + ans
		for x in range(cnt1 - 1):
			ans += '1 '
	print(ans)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	n = int(input())
	arr = input_split()
	s = sum(arr)
	if s <= n // 2:
		ans = [0] * (n // 2)
	elif n % 4 == 0:
		ans = [1] * (n // 2)
	else:
		ans = [1] * (n // 2 + 1)
	answers.append(ans)
for ans in answers:
	print(len(ans))
	print(*ans, sep=' ')


T = int(input())
for t in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	res = []
	for i in range(0, n, 2):
		if A[i] + A[i + 1] == 1:
			res.append(0)
		else:
			res += A[i:i + 2]
	print(len(res))
	for x in res:
		print(x, end=' ')
	print('')


for i in range(int(input())):
	n = int(input())
	a = str(input())
	if a.count('0') >= n / 2:
		print(int(n / 2))
		for i in range(int(n / 2)):
			print('0', end=' ')
	elif n / 2 % 2 == 0:
		print(int(n / 2))
		for i in range(int(n / 2)):
			print('1', end=' ')
	else:
		print(int(n / 2 + 1))
		for i in range(int(n / 2 + 1)):
			print('1', end=' ')


test = int(input())
for _ in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = a.count(0)
	if z >= n // 2:
		print(z)
		for i in range(n):
			if a[i] == 0:
				print(0, end=' ')
	else:
		if o % 2 != 0:
			o -= 1
		print(o)
		count = 0
		for i in range(n):
			if a[i] == 1:
				print(1, end=' ')
				count += 1
				if count == o:
					break
	print('')


def ahaha(arr, n):
	l = []
	c_1 = 0
	c_0 = 0
	for i in arr:
		if i == 0:
			c_0 += 1
		else:
			c_1 += 1
	if c_1 >= n // 2 and c_1 % 2 == 0:
		l = [1] * c_1
	elif c_1 > n // 2 and c_1 % 2:
		l = [1] * (c_1 - 1)
	elif c_1 == n // 2 and c_1 % 2:
		l = [0] * c_1
	elif c_1 < n // 2 and c_1 % 2 == 0:
		l = [0] * c_0
	elif c_1 < n // 2 and c_1 % 2:
		l = [0] * (c_0 - 1)
	print(len(l))
	return l
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = ahaha(arr, n)
	print(*res, sep=' ')


for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	N1 = a.count(1)
	N0 = n - N1
	if N0 >= n // 2:
		print(N0, N0 * '0 ', sep='\n')
	else:
		N1 -= N1 & 1
		print(N1, N1 * '1 ', sep='\n')


t = int(input())
for case in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	nz = 0
	no = 0
	for i in arr:
		if i == 0:
			nz += 1
		else:
			no += 1
	ans = []
	if nz >= no:
		ans = ['0'] * nz
	else:
		ans = ['1'] * no
	if no > nz and no % 2 == 1:
		ans.pop()
	print(len(ans))
	print(' '.join(ans))


x = int(input())
for i in range(0, x):
	n = int(input())
	m = list(map(int, input().split()))[:n]
	s = m.count(0)
	d = m.count(1)
	k = n // 2
	if s >= d:
		print(k)
		print('0 ' * k)
	elif k % 2 == 0:
		print(k)
		print('1 ' * k)
	else:
		print(k + 1)
		print('1 ' * (k + 1))


from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sum_odd = sum(a[0:len(a):2])
	sum_even = sum(a[1:len(a):2])
	if sum_odd == sum_even:
		print(len(a))
		for i in a:
			print(i, end=' ')
		print()
		continue
	if sum(a) <= len(a) // 2:
		print(len(a) - sum(a))
		print(' '.join(['0'] * (len(a) - sum(a))))
	else:
		print(sum(a) // 2 * 2)
		print(' '.join(['1'] * (sum(a) // 2 * 2)))


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
muin = lambda : map(int, input().split())
from math import ceil, sqrt, factorial
from collections import deque
from bisect import bisect_left

def solve():
	n = iin()
	l = lin()
	a = [0, 0]
	for i in l:
		a[i] += 1
	if a[0] >= n // 2:
		ans = [0] * (n // 2)
	elif n % 4 == 0:
		ans = [1] * (n // 2)
	else:
		ans = [1] * (n // 2 + 1)
	print(len(ans))
	print(*ans)
qwe = 1
qwe = int(input())
for _ in range(qwe):
	solve()


from sys import stdin
from collections import Counter
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	count = Counter(a)
	if count[0] < count[1]:
		res = count[1] - count[1] % 2
		print(res)
		print('1 ' * res)
	else:
		res = count[0]
		print(res)
		print('0 ' * res)


t = int(input())
ans = ''
for _ in range(t):
	n = int(input()) // 2
	a = [int(i) for i in input().split()]
	x = 0
	y = 0
	for i in range(2 * n):
		if a[i] == 1:
			x += 1
		else:
			y += 1
	if y >= n:
		ans += str(n) + '\n'
		for i in range(n):
			ans += '0 '
	elif n % 2 == 0:
		ans += str(n) + '\n'
		for i in range(n):
			ans += '1 '
	else:
		ans += str(n + 1) + '\n'
		for i in range(n + 1):
			ans += '1 '
	ans += '\n'
print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	a = b = 0
	for i in L:
		if i == 0:
			a = a + 1
		else:
			b = b + 1
	if a == 1 and b == 1:
		print(1)
		print(0, end=' ')
	elif a >= b:
		print(a)
		for i in range(a):
			print(0, end=' ')
	else:
		print(b - b % 2)
		for i in range(b - b % 2):
			print(1, end=' ')
	print()


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	zero = a.count(0)
	IND = []
	index = 0
	if zero >= n // 2:
		while index < n:
			if a[index] == 1:
				IND.append(index)
			index += 1
		index = 0
		while index < n:
			if index not in IND:
				b.append(a[index])
			index += 1
	else:
		while index < n:
			if a[index] == 0:
				IND.append(index)
			index += 1
		index = 0
		while index < n:
			if index not in IND:
				b.append(a[index])
			index += 1
		L = len(a) - len(IND)
		if L % 2 == 1:
			del b[0]
	print(len(b))
	B = ''
	for j in b:
		B += str(j) + ' '
	print(B)
	i += 1


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	seq = list(map(int, input().split()))
	countOne = seq.count(1)
	countZero = seq.count(0)
	sumEven = sumOdd = 0
	for i in range(n):
		if i % 2 == 0:
			sumEven += seq[i]
		else:
			sumOdd += seq[i]
	if countOne <= countZero:
		ans.append(countZero)
		ans.append([0] * countZero)
	else:
		if countOne % 2 == 1:
			countOne -= 1
		ans.append(countOne)
		ans.append([1] * countOne)
for el in ans:
	if type(el) == list:
		print(*el)
	else:
		print(el)


import math
for test in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	all_1 = True
	for i in a:
		if i != 1:
			all_1 = False
			break
	if all_1 is True:
		curr = len(a)
		if curr % 2 == 1:
			a.pop()
	else:
		val_after = []
		for i in range(n):
			val = 0
			for j in range(i + 1, n):
				temp = 0
				if j % 2 == 0:
					temp = a[j]
				else:
					temp = -a[j]
				val += temp
			val_after.append(val)
		curr = a[0] + val_after[0]
		if curr == 0:
			temp = 0
		else:
			for (idx, i) in reversed(list(enumerate(val_after))):
				val = 0
				if idx % 2 == 0:
					val = 2 * i + a[idx]
				else:
					val = 2 * i - a[idx]
				if curr == val:
					a.pop(idx)
					break
	print(len(a))
	for i in a:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	one = 0
	zero = 0
	for i in ar:
		if i == 0:
			zero += 1
		else:
			one += 1
	if n == 2:
		if zero == one:
			print(1)
			print(0)
		elif zero != 0:
			print(2)
			print(0, 0)
		else:
			print(2)
			print(1, 1)
	elif zero >= one:
		print(n // 2)
		print('0 ' * (n // 2))
	elif n % 4 == 0:
		print(n // 2)
		print('1 ' * (n // 2))
	else:
		print(n // 2 + 1)
		print('1 ' * (n // 2 + 1))


def tc():
	n = int(input())
	a = list(map(int, input().split()))
	(ones, zeros) = (0, 0)
	for x in a:
		if x:
			ones += 1
		else:
			zeros += 1
	if zeros >= n // 2:
		print(n // 2)
		print(' '.join(['0'] * (n // 2)))
	else:
		if ones % 2 == 1:
			ones -= 1
		print(ones)
		print(' '.join(['1'] * ones))
T = int(input())
for _ in range(T):
	tc()


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	c0 = 0
	c1 = 0
	for i in range(n):
		if l[i] == 1:
			c1 += 1
		else:
			c0 += 1
	if c0 >= c1:
		print(c0)
		print(*[0] * c0)
	else:
		if c1 % 2 != 0:
			c1 -= 1
		print(c1)
		print(*[1] * c1)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a0 = a.count(0)
	a1 = a.count(1)
	if a0 >= a1:
		print(n // 2)
		for j in range(n // 2):
			print('0', end=' ')
	else:
		if n // 2 % 2 != 0:
			n = n + 2
		print(n // 2)
		for j in range(n // 2):
			print('1', end=' ')
	print('')


from sys import stdin

def solve():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = [int(s) for s in input().split()]
		s = sorted(a)
		if s[n // 2 - 1] == 0:
			ans = '0' * (n // 2)
		else:
			k = a.count(1)
			if k % 2 == 0:
				ans = '1' * k
			else:
				ans = '1' * (k - 1)
		print(len(ans))
		print(' '.join(ans))
solve()


for i in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	num = nums.count(0)
	if num >= n // 2:
		print(n // 2)
		print(' '.join(('0' for i in range(n // 2))))
	elif n // 2 & 1:
		print(n // 2 + 1)
		print(' '.join(('1' for i in range(n // 2 + 1))))
	else:
		print(n // 2)
		print(' '.join(('1' for i in range(n // 2))))


for _ in range(int(input())):
	n = int(input())
	data = [int(x) for x in input().split()]
	one_count = 0
	for q in data:
		if q == 1:
			one_count += 1
	zero_count = n - one_count
	if one_count <= n // 2:
		print(n // 2)
		for q in range(n // 2):
			print(0, end=' ')
		print()
	elif one_count % 2:
		cnt = 0
		print(one_count - 1)
		for q in data:
			if cnt == one_count - 1:
				break
			if q == 1:
				cnt += 1
				print(1, end=' ')
		print()
	else:
		print(one_count)
		for q in range(one_count):
			print(1, end=' ')
		print()


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	z = arr.count(0)
	o = arr.count(1) // 2 * 2
	if z >= o:
		print(z)
		print(*[0] * z)
	else:
		print(o)
		print(*[1] * o)


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from itertools import permutations, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	d = []
	i = 0
	z = a.count(0)
	o = a.count(1)
	if z >= n // 2:
		ans = [0] * (n // 2)
	else:
		ans = [1] * (n // 2)
	if n // 2 % 2:
		if ans[0] == 1:
			if o - len(ans):
				ans.append(1)
	print(len(ans))
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	ali = list(map(int, input().split()))
	q = ali.count(0)
	w = ali.count(1)
	if q < n // 2:
		if w % 2 != 0:
			w -= 1
			print(w)
			a = [1] * w
			print(*a)
		else:
			print(w)
			a = [1] * w
			print(*a)
	else:
		print(q)
		a = [0] * q
		print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ones = a.count(1)
	zeroes = a.count(0)
	if zeroes >= ones:
		print(zeroes)
		print('0 ' * zeroes)
	else:
		if ones % 2 == 1:
			ones -= 1
		print(ones)
		print('1 ' * ones)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	zeros = 0
	ones = 0
	for i in range(n):
		if l[i] == 0:
			zeros += 1
		else:
			ones += 1
	temp = []
	if zeros < ones:
		for i in range(n):
			if l[i] == 1:
				temp.append(1)
		if len(temp) % 2 == 1:
			temp.pop(-1)
	else:
		for i in range(n):
			if l[i] == 0:
				temp.append(0)
	print(len(temp))
	print(*temp)


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = defaultdict(int)
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors[i] += 1
			n //= i
		i += 1
	if n > 1:
		factors[n] += 1
	return factors

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def a():
	n = int(input())
	arr = array()
	one = arr.count(1)
	zero = arr.count(0)
	if zero >= n // 2:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		one -= one % 2
		print(one)
		print(*[1] * one)

def b():
	n = int(input())
	arr = array()
	maxi = max(arr)
	ans = []
	for i in range(n):
		if maxi % arr[i] == 0:
			ans.append(arr[i])
	ans = sorted(ans, reverse=True)
	for i in range(n):
		if maxi % arr[i] != 0:
			ans.append(arr[i])
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	a()


def read_line():
	return list(map(int, input().split()))
T = int(input())
for _ in range(T):
	n = int(input())
	l = read_line()
	if sum(l) > n // 2:
		a = n // 2
		if a % 2 == 1:
			a += 1
		print(a)
		print(' '.join(map(str, [1] * a)))
	else:
		print(n - sum(l))
		print(' '.join(map(str, [0] * (n - sum(l)))))


T = int(input())
for I in range(0, T):
	N = int(input())
	X = input()
	O0 = X.count('0')
	O1 = X.count('1')
	if N == 2 and O1 != 2:
		print('1')
		print('0')
	elif N == 2 and O1 == 2:
		print('2')
		print('1 1')
	elif O0 < O1:
		print(int(N // 2 + 1) // 2 * 2)
		print(('1 ' * (int(N // 2 + 1) // 2 * 2)).strip())
	elif O0 > O1:
		print(int(N // 2 + 1) // 2 * 2)
		print(('0 ' * (int(N // 2 + 1) // 2 * 2)).strip())
	else:
		print(int(N // 2))
		print(('0 ' * int(N // 2)).strip())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(even, odd) = (0, 0)
	for i in range(n):
		if (i + 1) % 2 == 0:
			even += arr[i]
		else:
			odd += arr[i]
	if even == odd:
		print(n)
		for num in arr:
			print(num, end=' ')
		print()
	else:
		(zero, one) = (0, 0)
		for num in arr:
			if num == 0:
				zero += 1
			else:
				one += 1
		if zero >= n // 2:
			print(n // 2)
			for i in range(n // 2):
				print(0, end=' ')
		elif n // 2 % 2 == 0:
			print(n // 2)
			for i in range(n // 2):
				print(1, end=' ')
		else:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ')
		print()


n = int(input())
for x in range(n):
	k = int(input())
	s = sum(map(int, input().split()))
	if k - s >= k / 2:
		print(k - s)
		print(*[0 for _ in '_' * (k - s)])
	else:
		t = 0
		if s % 2:
			t = s - 1
		else:
			t = s
		print(t)
		print(*[1 for _ in '_' * t])


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	sum1 = []
	sum0 = []
	for num in range(n):
		if l[num] == 0:
			sum0.append(l[num])
		else:
			sum1.append(l[num])
	if len(sum1) > len(sum0):
		if len(sum1) % 2 == 0:
			print(len(sum1))
			print(*sum1)
		else:
			print(len(sum1) - 1)
			for ber in range(len(sum1) - 1):
				print(sum1[ber], end=' ')
			print()
	else:
		print(len(sum0))
		print(*sum0)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(str, input().split()))
	word = ''.join(arr)
	z = arr.count('0')
	zz = arr.count('1')
	if z >= zz:
		word = word.replace('1', '')
		print(len(word))
		for j in list(word):
			print(j, end=' ')
		print()
	else:
		word = word.replace('0', '')
		if len(word) % 2 != 0:
			word = word.replace('1', '', 1)
		print(len(word))
		for j in list(word):
			print(j, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	L = [int(x) for x in input().split()]
	one = L.count(1)
	zero = L.count(0)
	if one == len(L):
		print(n)
		print(*L)
	else:
		if one > zero:
			if n // 2 % 2 == 0:
				print(n // 2)
				for i in range(n // 2):
					print(1, end=' ')
			else:
				print(n // 2 + 1)
				for i in range(n // 2):
					print(1, end=' ')
				print(1, end=' ')
		else:
			print(n // 2)
			for i in range(n // 2):
				print(0, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	x = s.count(0)
	y = s.count(1)
	if y % 2 != 0:
		s.remove(1)
		y -= 1
		x += 1
		y += 1
	if x < y:
		print(n - x)
		for i in s:
			if i == 1:
				print(i, end=' ')
	else:
		print(n - y)
		for i in s:
			if i == 0:
				print(i, end=' ')
	print()


from sys import stdin

class Input:

	def readline(self):
		return stdin.readline().strip()

	def read_list(self):
		return self.readline().split()

	def read_ints(self):
		return list(map(int, self.read_list()))

	def known_tests(self):
		cases = self.read_ints()[0]
		for case in range(cases):
			yield self

	def single_test(self):
		yield self

class Problem:

	def __init__(self, input):
		(n,) = input.read_ints()
		a = input.read_ints()
		c = [0, 0]
		for i in a:
			c[i] += 1
		if c[0] == 0 or c[1] == 0:
			pass
		elif c[0] == c[1]:
			while 1 in a:
				a.remove(1)
		elif c[0] < c[1]:
			while 0 in a:
				a.remove(0)
			if len(a) % 2 == 1:
				a.remove(1)
		else:
			while 1 in a:
				a.remove(1)
		print(len(a))
		print(*tuple(a))
for test_input in Input().known_tests():
	Problem(test_input)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n):
	ones = arr.count(1)
	zero = n - ones
	if zero >= n // 2:
		res = [0] * (n // 2)
		write(n // 2)
		write(*res)
		return
	if ones >= n // 2:
		if ones & 1:
			res = [1] * (ones - 1)
			write(ones - 1)
			write(*res)
		else:
			res = [1] * ones
			write(ones)
			write(*res)

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(arr, n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


for _ in range(int(input())):
	n = int(input())
	b = [n - sum(list(map(int, input().split())))]
	b.append(n - b[0])
	i = 1 if b[1] * 2 > n else 0
	k = b[i] - b[i] % 2 * i
	print(k)
	print(*[i] * k)


from collections import Counter
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a = Counter(a)
	if a[0] >= a[1]:
		print(a[0])
		print(*[0] * a[0])
	elif a[1] % 2 == 0:
		print(a[1])
		print(*[1] * a[1])
	else:
		print(a[1] - 1)
		print(*[1] * (a[1] - 1))


def find_ans(n, s):
	fard_sum = 0
	zoj_sum = 0
	sefr = 0
	for i in range(n):
		if i % 2 == 0:
			zoj_sum += s[i]
		else:
			fard_sum += s[i]
		if s[i] == 0:
			sefr += 1
	if zoj_sum == fard_sum:
		print(n)
		print(*s)
		return
	ans = []
	if sefr < n // 2:
		sefr = 1
	else:
		sefr = 0
	for i in s:
		if i == sefr:
			ans.append(i)
	p = len(ans)
	if p % 2 == 1 and p != 1 and (ans[-1] == 1):
		del ans[-1]
		p -= 1
	print(p)
	print(*ans)
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	find_ans(n, s)


from sys import stdin, stdout
q = int(input())
for k in range(q):
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	sum0 = 0
	sum1 = 0
	for i in a:
		if i == 0:
			sum0 += 1
		else:
			sum1 += 1
	if sum0 >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	elif n // 2 % 2 != 0:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print(1, end=' ')
		print()
	else:
		print(n // 2)
		for i in range(n // 2):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	one = 0
	zero = 0
	for i in s:
		if i == 1:
			one += 1
		else:
			zero += 1
	h = n // 2
	if n == 2:
		if one == 2:
			print(2)
			print('1 1')
		else:
			print(1)
			print('0')
	elif h % 2 == 0:
		print(n - n // 2)
		if one >= n // 2:
			for i in range(n // 2):
				print('1', end=' ')
			print()
		elif zero >= n // 2:
			for i in range(n // 2):
				print('0', end=' ')
			print()
	elif one >= n // 2 + 1:
		print(n // 2 + 1)
		for i in range(n // 2 + 1):
			print('1', end=' ')
		print()
	elif zero >= n // 2:
		print(n - n // 2)
		for i in range(n // 2):
			print('0', end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	zc = sum((x == 0 for x in a))
	oc = n - zc
	if zc == oc:
		print(zc)
		print(*(0 for i in range(zc)))
	elif zc < oc:
		if zc % 2 == 1:
			print(oc - 1)
			print(*(1 for i in range(oc - 1)))
		else:
			print(oc)
			print(*(1 for i in range(oc)))
	elif oc % 2 == 1:
		print(zc - 1)
		print(*(0 for i in range(zc - 1)))
	else:
		print(zc)
		print(*(0 for i in range(zc)))


import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq
INF = 10 ** 20
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline().rstrip())
ns = lambda : map(int, sys.stdin.readline().rstrip().split())
na = lambda : list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda : list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))

def main():
	t = ni()
	for _ in range(t):
		n = ni()
		a = na()
		one = a.count(1)
		zero = a.count(0)
		if zero >= n // 2:
			print(n // 2)
			ans = [0] * (n // 2)
			print(*ans, sep=' ')
		else:
			res = n // 2
			if n // 2 % 2:
				res += 1
			print(res)
			ans = [1] * res
			print(*ans, sep=' ')
main()


def solve(n, ar):
	ans = []
	for i in range(0, n - 1, 2):
		if ar[i] == ar[i + 1]:
			ans.append(ar[i])
			ans.append(ar[i + 1])
			continue
		if ar[i] == 1:
			ans.append(ar[i + 1])
		elif ar[i + 1] == 1:
			ans.append(ar[i])
	print(len(ans))
	print(' '.join(map(str, ans)))
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	solve(n, ar)


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	n = int(input())
	half = int(n // 2)
	line = list(map(int, input().split()))
	count_1 = sum(line)
	count_0 = n - count_1
	if count_0 >= half:
		print(half)
		print(' '.join(['0'] * half))
	else:
		if half % 2 == 1:
			half += 1
		print(half)
		print(' '.join(['1'] * half))


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
M = 10 ** 9 + 7
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def toString(List):
	return ''.join(List)
p = []

def permute(a, l, r):
	if l == r:
		p.append(toString(a))
	else:
		for i in range(l, r + 1):
			(a[l], a[i]) = (a[i], a[l])
			permute(a, l + 1, r)
			(a[l], a[i]) = (a[i], a[l])

def squareRoot(number, precision):
	start = 0
	(end, ans) = (number, 1)
	while start <= end:
		mid = int((start + end) / 2)
		if mid * mid == number:
			ans = mid
			break
		if mid * mid < number:
			start = mid + 1
		else:
			end = mid - 1
	increment = 0.1
	for i in range(0, precision):
		while ans * ans <= number:
			ans += increment
		ans = ans - increment
		increment = increment / 10
	return ans
import math

def countRectangles(l, w):
	squareSide = math.gcd(l, w)
	return int(l * w / (squareSide * squareSide))

def count_same_digit(L, R):
	tmp = 0
	ans = 0
	n = int(math.log10(R) + 1)
	for i in range(0, n):
		tmp = tmp * 10 + 1
		for j in range(1, 10):
			if L <= tmp * j and tmp * j <= R:
				ans += 1
	return ans

def main():
	for _ in range(inpu()):
		n = inpu()
		arr = lis()
		one = arr.count(1)
		zero = arr.count(0)
		if one > zero:
			if one % 2 == 0:
				print(one)
				for _ in range(one):
					print(1, end=' ')
				print()
			else:
				print(one - 1)
				for _ in range(one - 1):
					print(1, end=' ')
				print()
		elif zero > one:
			if zero % 2 == 0:
				print(zero)
				for _ in range(zero):
					print(0, end=' ')
				print()
			else:
				print(zero - 1)
				for _ in range(zero - 1):
					print(0, end=' ')
				print()
		elif one % 2 == 0:
			print(one)
			for _ in range(one):
				print(0, end=' ')
		else:
			x = arr.count(0)
			if x >= n // 2:
				out = [0] * x
			else:
				out = [1] * ((n - x) // 2) * 2
			print(len(out))
			print(*out)
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	t1 = l.count(1)
	t2 = l.count(0)
	if n % 4 == 0:
		print(n // 2)
		if t1 >= n // 2:
			for i in range(n // 2):
				print(1, end=' ')
			print()
		else:
			for i in range(n // 2):
				print(0, end=' ')
			print()
	else:
		if t1 > n // 2:
			print(n // 2 + 1)
			for i in range(n // 2 + 1):
				print(1, end=' ')
		else:
			print(n // 2)
			for i in range(n // 2):
				print(0, end=' ')
		print()


for ctr in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(z, o) = (a.count(0), a.count(1))
	if z >= n // 2:
		print(z)
		for i in range(z):
			print(0, end=' ')
		print()
	else:
		print(o - o % 2)
		for i in range(o - o % 2):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = sum(arr)
	n //= 2
	if s > n:
		if n % 2 == 1:
			n += 1
		print(n)
		print(*[1] * n)
	else:
		print(n)
		print(*[0] * n)


t = input()
t = int(t)

def solve(n, arr):
	n1 = 0
	n0 = 0
	for x in arr:
		if x == 0:
			n0 += 1
		else:
			n1 += 1
	if n0 >= n1:
		print(n0)
		ans = [0] * n0
	elif n1 % 2 == 1:
		print(n1 - 1)
		ans = [1] * (n1 - 1)
	else:
		print(n1)
		ans = [1] * n1
	print(*ans)
for i in range(t):
	n = input()
	n = int(n)
	arr = list(map(int, input().split()))
	solve(n, arr)


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
mod = 1000000007
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	z = a.count(0)
	one = n - z
	if one <= n / 2:
		print(z)
		for i in a:
			if i != 1:
				print(i, end=' ')
		print()
		continue
	if one % 2 == 0:
		print(one)
		for i in a:
			if i != 0:
				print(i, end=' ')
		print()
	else:
		print(one - 1)
		z = []
		for i in a:
			if i != 0:
				z.append(i)
		print(*z[1:])


l = []
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	count1 = 0
	count0 = 0
	for i in range(n):
		if s[i] == 0:
			count0 = count0 + 1
		else:
			count1 = count1 + 1
	if count0 >= count1:
		l.append(n // 2)
		a = ['0' for i in range(n // 2)]
		l.append(' '.join(a))
	elif n % 4 == 0:
		l.append(n // 2)
		a = ['1' for i in range(n // 2)]
		l.append(' '.join(a))
	else:
		l.append(n // 2 + 1)
		a = ['1' for i in range(n // 2 + 1)]
		l.append(' '.join(a))
for i in l:
	print(i)


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().strip().split()))[:n]
	p = 0
	q = 0
	freq1 = {}
	for i in list1:
		if i in freq1:
			freq1[i] += 1
		else:
			freq1[i] = 1
	p = freq1.get(0, 0)
	q = freq1.get(1, 0)
	if p >= n // 2:
		print(n // 2)
		for i in range(0, n // 2):
			print(0, end=' ')
	elif q > n // 2:
		if n // 2 % 2 != 0:
			print(n // 2 + 1)
			for i in range(0, n // 2 + 1):
				print(1, end=' ')
		else:
			print(n // 2)
			for i in range(0, n // 2):
				print(1, end=' ')
	print()


tc = int(input())
for _ in range(tc):
	n = int(input())
	lis = list(map(int, input().split()))
	nlis = []
	start = 0
	while start < len(lis):
		if lis[start] == lis[start + 1]:
			nlis.append(lis[start])
			nlis.append(lis[start + 1])
			start += 2
		else:
			nlis.append(0)
			start += 2
	print(len(nlis))
	print(*nlis, sep=' ')


import sys
from math import ceil
from collections import deque
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = []
	for i in range(0, n, 2):
		if a[i] == 0 or a[i + 1] == 0:
			ans.append(0)
		else:
			ans.append(1)
			ans.append(1)
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(p) for p in input().split()]
	ones = arr.count(1)
	zeros = arr.count(0)
	if zeros >= ones:
		if zeros % 2 == 0:
			print(zeros // 2 * 2)
			print(*[0] * (zeros // 2 * 2))
		else:
			print(zeros // 2 * 2 + 1)
			print(*[0] * (zeros // 2 * 2 + 1))
	else:
		print(ones // 2 * 2)
		print(*[1] * (ones // 2 * 2))


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	one = sum(array)
	zero = n - one
	x = 11
	if n == x:
		print(int(x / 2))
		print('10' * int(x / 2))
	if zero < one:
		if one % 2 == 0:
			print(one)
			ans = '1 ' * one
			print(ans[:-1])
		else:
			print(one - 1)
			ans = '1 ' * (one - 1)
			print(ans[:-1])
	else:
		print(zero)
		ans = '0 ' * zero
		print(ans[:-1])


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	a = []
	tmp = 0
	sum = 0
	for j in range(0, len(s) - 1, 2):
		tmp += s[j] - s[j + 1]
	if tmp == 0:
		a = s
	else:
		for j in range(0, len(s) - 1, 2):
			if s[j] - s[j + 1] == 1:
				a.append(0)
			elif s[j] - s[j + 1] == -1:
				a.append(0)
			elif s[j] == 1 and s[j + 1] == 1:
				a.append(1)
				a.append(1)
			elif s[j] == 0 and s[j + 1] == 0:
				a.append(0)
				a.append(0)
	print(len(a))
	for k in a:
		print(k, end=' ')


n1 = int(input())
for test in range(n1):
	n = int(input())
	set1 = [int(y) for y in input().split()]
	zerocount = 0
	onecount = 0
	for i in range(n):
		if set1[i] == 0:
			zerocount = zerocount + 1
		else:
			onecount = onecount + 1
		k = int(n / 2)
	if onecount > zerocount:
		if k % 2 == 0:
			print(k)
			print('1 ' * k)
		else:
			print(k + 1)
			print('1 ' * (k + 1))
	else:
		print(k)
		print('0 ' * k)


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	zir = 0
	f = 0
	for i in range(n):
		if a[i] == 0:
			zir += 1
		else:
			f += 1
	if zir >= n // 2:
		print(zir)
		for i in range(zir):
			print(0, end=' ')
	else:
		f -= f % 2
		print(f)
		cur = 0
		for i in range(f):
			print(1, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = input().replace(' ', '')
	cn = 0
	for i in a:
		if i == '1':
			cn += 1
	if cn <= n // 2:
		print(n - cn)
		for i in range(n - cn):
			print('0', end=' ')
	else:
		if cn % 2 != 0:
			cn -= 1
		print(cn)
		for i in range(cn):
			print('1', end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	count0 = arr.count(0)
	count1 = arr.count(1)
	if count0 >= n // 2:
		print(count0)
		for i in range(count0):
			print(0, end=' ')
	else:
		print(count1 - count1 % 2)
		for i in range(count1 - count1 % 2):
			print(1, end=' ')
	print()
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	ans = []
	(z, one) = (a.count(0), a.count(1))
	if z >= one:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		print(one // 2 * 2)
		print(*[1] * (one // 2 * 2))


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for i in range(t):
	n = iinput()
	a = rlinput()
	count1 = a.count(1)
	count0 = n - count1
	ans = []
	if count0 >= n // 2:
		ans = [0] * (n // 2)
	elif count1 % 2 == 0:
		ans = [1] * count1
	else:
		ans = [1] * (count1 - 1)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	one = list(map(int, input().split()))
	one = len([x for x in one if x == 1])
	zero = n - one
	if zero >= n // 2:
		print(zero)
		print(*['0'] * zero)
	else:
		if one % 2 == 1:
			one -= 1
		print(one)
		print(*['1'] * one)


import sys, copy
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	arr.sort()
	zero = []
	one = []
	for i in arr:
		if i:
			one.append(i)
		else:
			zero.append(i)
	if len(one) >= n // 2:
		if n // 2 % 2 == 0:
			print(n // 2)
			print(' '.join(map(str, one[:n // 2])))
		elif len(zero) >= n // 2:
			print(n // 2)
			print(' '.join(map(str, zero[:n // 2])))
		else:
			print(n // 2 + 1)
			print(' '.join(map(str, one[:n // 2 + 1])))
	elif len(zero) >= n // 2:
		print(n // 2)
		print(' '.join(map(str, zero[:n // 2])))


from sys import stdin, stdout

def find(arr, N):
	a = arr.count(1)
	b = arr.count(0)
	K = N - N // 2
	if b >= K:
		return [0] * K
	if a > K:
		return [1] * (K + 1 if K % 2 else K)
	if a == K and K % 2 == 0:
		return [1] * K
	x = arr.count(0)
	A = [1] * x + [0] + [1] * (K - x)
	if x % 2 == 0:
		del A[-1]
	else:
		del A[0]
	return A

def main():
	for _ in range(int(stdin.readline())):
		N = int(stdin.readline())
		arr = list(map(int, stdin.readline().split()))
		Z = find(arr, N)
		print(len(Z))
		print(' '.join(map(str, Z)))
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	total_imbalance = 0
	for i in range(n):
		total_imbalance += a[i] * (-1) ** i
	if total_imbalance % 2 == 0:
		current_imbalance = 0
		for i in range(n):
			current_imbalance += a[i] * (-1) ** i
			if a[i] == 0 and current_imbalance == total_imbalance // 2:
				a.pop(i)
				break
	else:
		if total_imbalance < 0:
			goal = total_imbalance // 2
		else:
			goal = total_imbalance // 2 + 1
		current_imbalance = 0
		for i in range(n):
			current_imbalance += a[i] * (-1) ** i
			if (-1) ** i * total_imbalance > 0 and a[i] == 1 and (current_imbalance == goal):
				a.pop(i)
				break
	print(len(a))
	print(*a)


from sys import stdin, stdout
from math import gcd, log2, log10, floor
import math
from collections import defaultdict
input = stdin.readline

def count(a, i):
	return a.count(i)
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	zeros = count(a, 0)
	ones = count(a, 1)
	if zeros >= ones:
		print(zeros)
		print(*[0] * zeros)
	else:
		if ones % 2 == 1:
			ones -= 1
		print(ones)
		print(*[1] * ones)


def pos(arr, n):
	evenP = []
	oddP = []
	for i in range(len(arr)):
		if i % 2 == 0 and arr[i] == 1:
			evenP.append(i)
		if i % 2 != 0 and arr[i] == 1:
			oddP.append(i)
	if n == 1:
		return oddP
	else:
		return evenP

def haha(arr):
	even = arr[0::2]
	odd = arr[1::2]
	n = len(arr) // 2
	i = n
	if arr.count(1) <= n:
		blanck = [0] * (len(arr) - arr.count(1))
		print(len(blanck))
		for i in blanck:
			print(i, end=' ')
		return ''
	if arr.count(0) < n:
		c = 0
		if arr.count(1) % 2 != 0:
			c = 1
		blanck = [1] * (len(arr) - arr.count(0) - c)
		print(len(blanck))
		for i in blanck:
			print(i, end=' ')
		return ''
	print(len(arr))
	for i in arr:
		print(i, end=' ')
	return ''
t = int(input())
for i in range(t):
	a = input()
	lst = list(map(int, input().strip().split()))
	print(haha(lst))


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	a = inl()
	if n == 2:
		if a[0] == a[1]:
			print(2)
			print(*a)
		else:
			print(1)
			print(0)
		continue
	cnt = [0] * (n // 2)
	for i in range(0, n, 2):
		if a[i] == a[i + 1]:
			cnt[i // 2] = 1
		if a[i] == 0 and a[i + 1] == 1:
			cnt[i // 2] = 2
		if a[i] == 1 and a[i + 1] == 0:
			cnt[i // 2] = 3
	alter = False
	if cnt.count(2) == 0 and cnt.count(3) == 0:
		cnt2 = cnt3 = 0
	elif cnt.count(2) == 0 or cnt.count(3) == 0:
		alter = True
		cnt2 = cnt.count(2)
		cnt3 = cnt.count(3)
	else:
		cnt2 = cnt3 = min(cnt.count(2), cnt.count(3))
	ans = []
	k = 1
	for i in range(n // 2):
		if cnt[i] == 0:
			continue
		if cnt[i] == 2 and cnt2 == 0:
			continue
		if cnt[i] == 3 and cnt3 == 0:
			continue
		if alter and cnt[i] in [2, 3]:
			if cnt[i] == 2:
				ans.append(a[i * 2])
			else:
				ans.append(a[i * 2 + 1])
		else:
			ans.append(a[i * 2])
			ans.append(a[i * 2 + 1])
		if cnt[i] == 2:
			cnt2 -= 1
		if cnt[i] == 3:
			cnt3 -= 1
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	oneCount = 0
	zeroCount = 0
	for elem in a:
		if elem == 1:
			oneCount += 1
		else:
			zeroCount += 1
	if zeroCount >= n // 2:
		print(zeroCount)
		print(' '.join(['0'] * zeroCount))
	else:
		print(oneCount // 2 * 2)
		print(' '.join(['1'] * (oneCount // 2 * 2)))


t = int(input())
for _ in range(t):
	n = int(input())
	cnt0 = 0
	a = []
	a = [int(i) for i in input().split()]
	for i in range(len(a)):
		if a[i] == 0:
			cnt0 += 1
	cnt1 = n - cnt0
	if cnt0 >= n / 2:
		print(cnt0)
		for i in range(cnt0):
			print(0)
	else:
		print(cnt1 - cnt1 % 2)
		for i in range(cnt1 - cnt1 % 2):
			print(1)


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	if sum(lst) <= n // 2:
		print(n // 2)
		print('0 ' * (n // 2))
	else:
		print(n // 2 + n // 2 % 2)
		print('1 ' * (n // 2 + n // 2 % 2))
for i in range(int(input())):
	solve()


for i in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	s = n // 2
	a = l.count(1)
	b = l.count(0)
	k = []
	if b >= s:
		for j in range(s):
			k.append(0)
	elif s % 2 != 0:
		for j in range(s + 1):
			k.append(1)
	else:
		for j in range(s):
			k.append(1)
	print(len(k))
	print(*k)


t = int(input())
for i in range(t):
	n = int(input())
	listA = list(map(int, input().strip().split(' ')))[:n]
	i = 0
	while i < n - 1:
		if listA[i] == 1:
			if listA[i + 1] == 1:
				i += 2
			else:
				del listA[i]
				i += 1
				n -= 1
		else:
			i += 1
	if i == n - 1 and listA[i] == 1:
		del listA[n - 1]
		n -= 1
	print(n)
	for i in listA:
		print(i, end=' ')
	print()


n = int(input())
for i in range(n):
	k = int(input())
	L1 = [int(i) for i in input().strip('\r').split(' ')]
	count_0 = 0
	count_1 = 0
	for i in range(len(L1)):
		if L1[i] == 1:
			count_1 += 1
		else:
			count_0 += 1
	if count_1 <= k // 2:
		result = ['0'] * count_0
	if count_0 < k // 2:
		result = ['1'] * count_1
		if count_0 % 2 != 0:
			result.pop()
	print(len(result))
	print(' '.join(result))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	zeroes = 0
	ones = 0
	output = ''
	for num in a:
		if num == 0:
			zeroes += 1
		else:
			ones += 1
	if zeroes >= n // 2:
		print(zeroes)
		print('0 ' * zeroes)
	else:
		print(ones - ones % 2)
		print('1 ' * (ones - ones % 2))


def even_spliter(arr):
	l = len(arr)
	gen = list()
	one = arr.count('1')
	zero = arr.count('0')
	if one > zero:
		for i in range(one):
			gen.append('1')
		if not one % 2 == 0:
			gen.pop()
	else:
		for i in range(zero):
			gen.append('0')
	return gen
t = input()
for i in range(int(t)):
	number = input()
	number = int(number)
	line = input()
	arr = line.split()
	gen = even_spliter(arr)
	str1 = ''
	for ele in gen:
		str1 = str1 + ' ' + ele
	print(len(gen))
	print(str1.strip())


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	suml = sum(l)
	if suml <= n / 2:
		print(n - suml)
		print(*[0 for _ in range(n - suml)])
	else:
		count = suml - suml % 2
		print(count)
		print(*[1 for _ in range(count)])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import Counter, defaultdict, deque

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))
mod = pow(10, 9) + 7

def solve():
	n = int1()
	l1 = list1()
	c1 = l1.count(0)
	c2 = l1.count(1)
	if c1 >= c2:
		if 1:
			l1 = [0] * c1
			print(c1)
			print(*l1)
	elif c2 % 2 == 1:
		l1 = [1] * (c2 - 1)
		print(c2 - 1)
		print(*l1)
	else:
		l1 = [1] * c2
		print(c2)
		print(*l1)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt0 = arr.count(0)
	cnt1 = arr.count(1)
	if cnt1 <= int(n / 2):
		print(n - cnt1)
		print(' '.join(['0'] * (n - cnt1)))
	elif cnt0 <= n / 2:
		if cnt1 % 2 == 1:
			print(cnt1 - 1)
			print(' '.join(['1'] * (cnt1 - 1)))
		else:
			print(cnt1)
			print(' '.join(['1'] * cnt1))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x0 = a.count(0)
	x1 = a.count(1)
	if x0 < n // 2:
		if x1 % 2 == 0:
			print(x1)
			print('1 ' * x1)
		else:
			print(x1 - 1)
			print('1 ' * (x1 - 1))
	else:
		print(x0)
		print('0 ' * x0)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = l.count(1)
	z = l.count(0)
	if o <= n // 2:
		print(z)
		print(*[0] * z)
	elif o % 2:
		print(o - 1)
		print(*[1] * (o - 1))
	else:
		print(o)
		print(*[1] * o)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = a.count(0)
	if o > n // 2:
		ans = [1] * (n // 2)
		if n // 2 & 1:
			ans += [1]
	else:
		ans = [0] * (n // 2)
	print(len(ans))
	print(*ans)


import sys
from collections import Counter

def main():
	tn = int(input())
	for ti in range(tn):
		n = int(input())
		C = Counter((int(x) for x in input().split()))
		if C[0] == 0:
			print(n)
			print('1 ' * n)
		elif C[0] >= C[1]:
			print(n // 2)
			print('0 ' * (n // 2))
		else:
			print(n // 2 + n // 2 % 2)
			print('1 ' * (n // 2 + n // 2 % 2))
main()


def balanceArray(arr):
	l = len(arr)
	noZeroes = 0
	for i in arr:
		if i == 0:
			noZeroes += 1
	noOnes = l - noZeroes
	if noOnes <= l / 2:
		return [0] * noZeroes
	elif noOnes % 2 == 0:
		return [1] * noOnes
	else:
		return [1] * (noOnes - 1)
T = int(input())
for _ in range(T):
	N = int(input())
	arr = list(map(int, input().split()))
	res = balanceArray(arr)
	print(len(res))
	print(*res)


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def I():
	return int(sys.stdin.readline())

def neo():
	return map(int, sys.stdin.readline().split())

def Neo():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	n = I()
	A = Neo()
	if A.count(0) >= n // 2:
		print(n // 2)
		A = [0] * (n // 2)
		print(*A)
	elif n % 4 == 0:
		print(n // 2)
		A = [1] * (n // 2)
		print(*A)
	else:
		print(n // 2 + 1)
		A = [1] * (n // 2 + 1)
		print(*A)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	cnt = sum(a) // 2 * 2
	ans = []
	zero = 0
	for i in range(n):
		if a[i] == 0:
			zero += 1
		elif cnt != 0:
			for j in range(zero // 2):
				ans.append(0)
				ans.append(0)
			zero = 0
			ans.append(1)
			cnt -= 1
		if i == n - 1:
			for j in range(zero):
				ans.append(0)
	print(len(ans))
	print(*ans)
testcase(int(inp()))


for _ in range(int(input())):
	leng = int(input())
	array = list(map(int, input().split()))
	zero = 0
	one = 0
	for i in array:
		if i == 1:
			one += 1
		else:
			zero += 1
	if zero >= leng // 2:
		print(leng // 2)
		print('0 ' * (leng // 2))
	elif leng // 2 % 2 == 0:
		print(leng // 2)
		print('1 ' * (leng // 2))
	else:
		print(leng // 2 + 1)
		print('1 ' * (leng // 2 + 1))


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	arr = iia()
	e = o = 0
	even = []
	odd = []
	for i in range(n):
		if (i + 1) % 2 != 0:
			o += arr[i]
		else:
			e += arr[i]
	if e == o:
		print(n)
		print(*arr)
	else:
		count = 0
		ans = []
		i = 0
		while i < len(arr):
			if arr[i] == 0:
				ans.append(arr[i])
				i += 1
			elif i + 1 < n and arr[i + 1] == 1:
				ans.extend([1, 1])
				i += 2
			else:
				i += 1
		print(len(ans))
		print(*ans)


T = int(input())
while T:
	n = int(input())
	arr = list(map(str, input().split()))
	c = 0
	i = 0
	while i < n:
		if arr[i] == '1':
			c += 1
			pass
		else:
			if c % 2 != 0:
				del arr[i - 1]
				i -= 1
				n -= 1
			c = 0
		i += 1
	if c % 2 != 0:
		del arr[-1]
	print(len(arr))
	print(*arr)
	T -= 1


for tc in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	count1 = 0
	count2 = 0
	for x in lst:
		if x == 0:
			count2 += 1
		if x == 1:
			count1 += 1
	if count2 >= count1:
		print(count2)
		for i in range(count2):
			print(0, end=' ')
		print()
	elif count1 % 2 == 0:
		print(count1)
		for i in range(count1):
			print(1, end=' ')
		print()
	else:
		count1 = count1 - 1
		print(count1)
		for i in range(count1):
			print(1, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(z, o) = (0, 0)
	for x in a:
		if x == 0:
			z += 1
		else:
			o += 1
	b = []
	if o > n // 2:
		b = [1] * (o - 1) if o & 1 else [1] * o
	else:
		b = [0] * z
	print(len(b))
	print(*b)


remaining_test_cases = int(input())
for _ in range(remaining_test_cases):
	N = int(input())
	list_of_0_and_1 = list(map(int, input().split()))
	count_number_of_zeroes = 0
	count_number_of_ones = 0
	for i in range(len(list_of_0_and_1)):
		if list_of_0_and_1[i] == 0:
			count_number_of_zeroes = count_number_of_zeroes + 1
		else:
			count_number_of_ones = count_number_of_ones + 1
	if count_number_of_ones % 2 == 0:
		if count_number_of_ones < count_number_of_zeroes:
			print(count_number_of_zeroes)
			for i in range(count_number_of_zeroes):
				print('0', end=' ')
		else:
			print(count_number_of_ones)
			for i in range(count_number_of_ones):
				print('1', end=' ')
	elif count_number_of_ones <= count_number_of_zeroes:
		print(count_number_of_zeroes)
		for i in range(count_number_of_zeroes):
			print('0', end=' ')
	else:
		print(count_number_of_ones - 1)
		for i in range(count_number_of_ones - 1):
			print('1', end=' ')


for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	n1 = lst.count(1)
	n0 = lst.count(0)
	if n0 >= n // 2:
		print(n // 2)
		for i in range(n // 2):
			print(0, end=' ')
		print()
	elif n1 % 2 == 0:
		print(n1)
		for i in range(n1):
			print(1, end=' ')
		print()
	else:
		print(n1 - 1)
		for i in range(n1 - 1):
			print(1, end=' ')
		print()


for it in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	c1 = a.count(1)
	if c1 <= n - c1:
		print(n // 2)
		print(*[0] * (n // 2))
	else:
		k = n // 2
		if k % 2 == 1:
			k += 1
		print(k)
		print(*[1] * k)


from collections import Counter
CASES = int(input())
for _ in range(CASES):
	n = int(input())
	dic = Counter(map(int, input().split()))
	n1 = dic[0]
	n2 = dic[1]
	if n2 > n1:
		if n2 % 2 == 0:
			print(n2)
			ans = [1 for i in range(n2)]
			print(*ans)
		else:
			print(n2 - 1)
			ans = [1 for i in range(n2 - 1)]
			print(*ans)
	else:
		print(n1)
		ans = [0 for i in range(n1)]
		print(*ans)


from sys import stdin, stdout

def input():
	a = stdin.readline()
	if a[-1] == '\n':
		a = a[:-1]
	return a

def print(*argv, end='\n', sep=' '):
	n = len(argv)
	for i in range(n):
		if i == n - 1:
			stdout.write(str(argv[i]))
		else:
			stdout.write(str(argv[i]) + sep)
	stdout.write(end)
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, lst):
	z = 0
	for i in lst:
		if i == '0':
			z += 1
	o = n - z
	if z >= o:
		print(z)
		print('0 ' * z)
	else:
		o = 2 * (o // 2)
		print(o)
		print('1 ' * o)
for _ in range(int(input())):
	n = int(input())
	lst = ''.join(input().split())
	solve(n, lst)


for t in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	ans = []
	if a.count(0) >= a.count(1):
		ans = [0] * (n // 2)
	else:
		m = n // 2 + n // 2 % 2
		ans = [1] * m
	print(len(ans))
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	count_one = a.count(1)
	count_zero = a.count(0)
	if count_zero >= count_one:
		print(count_zero)
		print('0 ' * count_zero)
	else:
		if count_one % 2 != 0:
			count_one -= 1
		print(count_one)
		print('1 ' * count_one)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = c = 0
	for i in a:
		if i == 1:
			b += 1
		else:
			c += 1
	if b > c:
		flag = 1
	else:
		flag = 0
	d = [0 for i in range(n)]
	f = False
	curr = False
	lol = 0
	for i in range(0, n, 2):
		if a[i] == a[i + 1]:
			d[i] = a[i]
			d[i + 1] = a[i + 1]
			lol = 0
			continue
			f = False
		elif a[i] == flag:
			curr = False
			if flag == 0:
				d[i + 1] = 20
			else:
				d[i] = 20
			lol += 1
		else:
			curr = True
			if flag == 0:
				d[i] = 20
			else:
				d[i + 1] = 20
			lol += 1
		if lol == 2 and curr == prev:
			d[i] = 20
			d[i - 2] = 20
			d[i + 1] = a[i + 1]
			d[i - 1] = a[i - 1]
			lol = 0
		elif lol == 2 and curr != prev:
			d[i] = a[i]
			d[i - 2] = a[i - 2]
			d[i + 1] = a[i + 1]
			d[i - 1] = a[i - 1]
			lol = 0
		if lol == 1:
			prev = curr
	ans = []
	for i in d:
		if i < 10:
			ans.append(i)
	print(len(ans))
	print(*ans)


def alternating_sum(n, seq):
	ones = len([x for x in seq if x == '1'])
	zeros = n - ones
	if zeros >= n // 2:
		return ['0'] * zeros
	elif ones % 2 == 0:
		return ['1'] * ones
	else:
		return ['1'] * (ones - 1)
t = int(input())
for x in range(t):
	n = int(input())
	seq = input().split()
	ans = alternating_sum(n, seq)
	print(len(ans), ' '.join(ans), sep='\n')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	lst = []
	i = 0
	while i < len(l) - 1:
		if l[i]:
			if l[i + 1]:
				lst.extend([1, 1])
				i += 1
			elif i + 2 < n and l[i + 2]:
				lst.extend([1, 1])
				i += 2
		elif not l[i + 1]:
			lst.extend([0, 0])
			i += 1
		elif i + 2 < n and (not l[i + 2]):
			lst.extend([0, 0])
			i += 2
		i += 1
	if len(lst):
		print(len(lst))
		print(*lst)
	else:
		print(1)
		print(0)


for __ in ' ' * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	cnt0 = a.count(0)
	cnt1 = a.count(1)
	if cnt0 >= cnt1:
		print(cnt0)
		print('0 ' * cnt0)
	else:
		print(cnt1 // 2 * 2)
		print('1 ' * (cnt1 // 2) * 2)


cases = int(input())
for _ in range(cases):
	n = int(input())
	c = list(map(int, input().split()))
	if c.count(1) <= n // 2:
		t = c.count(1)
		for i in range(t):
			c.remove(1)
		print(len(c))
		print(*c)
	else:
		t = c.count(0)
		for i in range(t):
			c.remove(0)
		if len(c) % 2 == 0:
			print(len(c))
			print(*c)
		else:
			c.remove(1)
			print(len(c))
			print(*c)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s0 = 0
	s1 = 0
	for i in range(n):
		if a[i] == 0:
			s0 += 1
		else:
			s1 += 1
	if s0 >= s1:
		print(s0)
		for j in range(s0):
			print('0 ', end='')
	else:
		if s1 & 1:
			s1 -= 1
		print(s1)
		for j in range(s1):
			print('1 ', end='')
	print()


def count(a=[], x=0):
	count = 0
	for i in range(len(a)):
		if a[i] == x:
			count += 1
	return count

def sol():
	n = int(input())
	a = [int(i) for i in input().split()]
	cnt0 = count(a)
	cnt1 = n - cnt0
	if cnt0 >= n // 2:
		for i in range(n - cnt0):
			a.remove(1)
		print(len(a))
		for i in range(len(a)):
			print(a[i], end=' ')
		print()
	elif cnt1 % 2 == 0:
		for i in range(n - cnt1):
			a.remove(0)
		print(len(a))
		for i in range(len(a)):
			print(a[i], end=' ')
		print()
	elif cnt0 != 1 or n == 2:
		for i in range(n - cnt1):
			a.remove(0)
		a.remove(1)
		print(len(a))
		for i in range(len(a)):
			print(a[i], end=' ')
		print()
	else:
		a.remove(1)
		a.remove(0)
		print(len(a))
		for i in range(len(a)):
			print(a[i], end=' ')
		print()
t = int(input())
while t > 0:
	t -= 1
	sol()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	b = []
	(add, store) = (0, 0)
	while True:
		if i < n - 3:
			if a[i] == a[i + 1]:
				b.append(a[i])
				b.append(a[i + 1])
				i += 2
			elif a[i] != a[i + 1] and a[i] == a[i + 2]:
				b.append(a[i])
				b.append(a[i + 2])
				i += 3
			elif a[i] != a[i + 1] and a[i] != a[i + 2]:
				b.append(a[i + 1])
				b.append(a[i + 2])
				i += 3
		else:
			j = i
			while j < n:
				if a[j] == 1:
					add += 1
				else:
					store += 1
				j += 1
			if add >= 2:
				b.append(1)
				b.append(1)
			elif store > 0:
				for i in range(store):
					b.append(0)
			break
	print(len(b))
	for k in b:
		print(k, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	odd = 0
	even = 0
	(x, y) = (0, 0)
	for i in range(len(a)):
		if a[i] == 1:
			x = x + 1
		else:
			y = y + 1
	if x > y:
		if x % 2 == 0:
			print(x)
			print('1 ' * x, end=' ')
		else:
			print(x - 1)
			print('1 ' * (x - 1), end=' ')
	else:
		print(y)
		print('0 ' * y, end=' ')
	print()


def solution():
	n = int(input())
	c0 = 0
	c1 = 0
	l = list(map(int, input().split()))
	for i in range(n):
		a = l[i]
		if a == 0:
			c0 += 1
		else:
			c1 += 1
	if c0 >= c1:
		print(c0)
		for i in range(c0):
			print(0, end=' ')
	elif c0 < c1:
		print(c1 - c1 % 2)
		for i in range(c1 - c1 % 2):
			print(1, end=' ')
	print('')
t = int(input())
while t > 0:
	solution()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	zer = lis.count(0)
	one = n - zer
	if one > zer:
		o = [1 for i in range(n // 2)]
		n = n // 2
		if n % 2:
			o += [1]
			print(n + 1)
			print(*o)
		else:
			print(n)
			print(*o)
	else:
		n = n // 2
		z = [0 for i in range(n)]
		print(n)
		print(*z)


for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	ones = 0
	for i in range(n):
		if arr[i] == 1:
			ones += 1
	if ones <= n // 2:
		print(n - ones)
		print(*[0 for j in range(n - ones)])
	elif ones % 2:
		print(ones - 1)
		print(*[1 for j in range(ones - 1)])
	else:
		print(ones)
		print(*[1 for j in range(ones)])


n = int(input())
for i in range(n):
	n1 = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	k = 0
	l = 0
	j = 0
	while j < len(a):
		if a[j] == 1:
			k += 1
		elif a[j] == 0:
			if k % 2 == 0:
				k = 0
			else:
				del a[j - 1]
				k = 0
				j -= 1
		j += 1
	if k % 2 == 0:
		k = 0
	else:
		del a[j - 1]
	print(len(a))
	print(*a)


import sys
input = sys.stdin.readline
cases = int(input())
for case in range(cases):
	n = int(input())
	a = [int(x) for x in input().split()]
	(z, o) = (0, 0)
	for i in range(len(a)):
		if a[i] == 1:
			z += 1
		else:
			o += 1
	if z > o:
		if z & 1:
			z -= 1
		print(z)
		s = '1 ' * z
		print(s)
	else:
		print(o)
		s = '0 ' * o
		print(s)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, func=lambda a, b: a & b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	one = []
	zer = []
	for i in range(n):
		if l[i] == 1:
			one.append(1)
		else:
			zer.append(0)
	if len(one) > n // 2:
		if len(one) % 2 == 1:
			one = one[1:]
		print(len(one))
		print(*one)
	else:
		print(len(zer))
		print(*zer)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def alt_sum(a, n):
	s = 0
	for i in range(n):
		if i & 1:
			s -= a[i]
		else:
			s += a[i]
	return s

def check(a, k):
	c = 0
	z = 0
	for i in range(len(a)):
		if a[i] == 1:
			c += 1
		if c >= k - 1:
			if a[i] == 0:
				z += 1
	return z > 0

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	if alt_sum(a, n) == 0:
		print(n)
		print(*a)
	elif n // 2 % 2 == 0:
		(one, zero) = (a.count(1), a.count(0))
		if zero >= n // 2:
			print(n // 2)
			print(*[0] * (n // 2))
		else:
			print(n // 2)
			print(*[1] * (n // 2))
	else:
		(one, zero) = (a.count(1), a.count(0))
		if zero >= n // 2:
			print(n // 2)
			print(*[0] * (n // 2))
		else:
			print(n // 2)
			if check(a, n // 2):
				print(*[1] * (n // 2 - 1) + [0])
			else:
				print(*[0] + [1] * (n // 2 - 1))
for _ in range(int(input())):
	solve()


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	temparr = input()
	temparr = temparr.split()
	count0 = 0
	count1 = 0
	for i in temparr:
		if i == '0':
			count0 += 1
		else:
			count1 += 1
	half = n // 2
	ans = []
	if count1 <= half:
		ans = ['0' for _ in range(count0)]
		print(len(ans))
		print(' '.join(ans))
	else:
		if count1 & 1 == 1:
			ans = ['1' for _ in range(count1 - 1)]
		else:
			ans = ['1' for _ in range(count1)]
		print(len(ans))
		print(' '.join(ans))


for s in [*open(0)][2::2]:
	r = '0'.join((x[len(x) % 2:] for x in s[::2].split('0')))
	print(len(r), *r)