------
## 最终结论
```python
def read_input():
    import sys
    input = sys.stdin.read
    data = input().split()
    return data

data = read_input()

index = 0
t = int(data[index])
index += 1

results = []

for _ in range(t):
    n = int(data[index])
    index += 1
    a = list(map(int, data[index:index + n]))
    index += n
    
    count_ones = a.count(1)
    count_zeros = n - count_ones
    
    if count_ones >= n // 2:
        # We need to keep at least n//2 ones
        result_array = [1] * (n // 2)
    else:
        # We need to keep at least n//2 zeros
        result_array = [0] * (n // 2)
    
    results.append((len(result_array), result_array))

for k, arr in results:
    print(k)
    print(' '.join(map(str, arr)))
```