Ahahahahahahahaha

Alexandra has an even-length array a, consisting of 0 s 0s 0s and 1 s 1s 1s. The elements of the array are enumerated from 1 1 1 to n n n. She wants to remove at most n 2 \frac{n}{2} 2n 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 + … = 0 a_1−a_2+a_3−a_4+…=0 a1a2+a3a4+=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 ] a=[1,0,1,0,0,0] a=[1,0,1,0,0,0] and she removes 2nd and 4th elements, a will become equal [ 1 , 1 , 0 , 0 ] [1,1,0,0] [1,1,0,0] and its alternating sum is 1 − 1 + 0 − 0 = 0 1−1+0−0=0 11+00=0.

Help her!

Input

Each test contains multiple test cases. The first line contains the number of test cases t ( 1 ≤ t ≤ 1 0 3 ) t (1≤t≤10^3) t(1t103). Description of the test cases follows.

The first line of each test case contains a single integer n ( 2 ≤ n ≤ 1 0 3 n (2≤n≤10^3 n(2n103, n n n is even) — length of the array.

The second line contains n n n integers a 1 , a 2 , … , a n a_1,a_2,…,a_n a1,a2,,an ( 0 ≤ a i ≤ 1 ) (0≤a_i≤1) (0ai1) — elements of the array.

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

Output

For each test case, firstly, print k ( n 2 ≤ k ≤ n ) k (\frac{n}{2}≤k≤n) k(2nkn) — number of elements that will remain after removing in the order they appear in a. Then, print this k k 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 0 0.

In the third case, alternating sum of the array equals 1 − 1 = 0 1−1=0 11=0.

In the fourth case, alternating sum already equals 1 − 1 + 0 − 0 = 0 1−1+0−0=0 11+00=0, so we don’t have to remove anything.

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn],n,num0,num1;
int main() {
    int _;
    scanf("%d", &_);
    while (_--) {
        num0 = num1 = 0;
        scanf("%d", &n);
        for (int i = 1, x; i <= n; i++) {
            scanf("%d", &x);
            if (!x) num0++; else num1++;
        }
        if (num0 == num1) {
            printf("%d\n", n / 2);
            for (int i = 1; i <= n / 2; i++) {
                printf("0 ");
            }
        }
        if (num0 > num1) {
            printf("%d\n", n / 2);
            for (int i = 1; i <= n / 2; i++) {
                printf("0 ");
            }
        }
        if (num0 < num1) {
            if (num1 % 2 == 0) {
                printf("%d\n", num1);
                for (int i = 1; i <= num1; i++) {
                    printf("1 ");
                }
            } else {
                printf("%d\n", num1 - 1);
                for (int i = 1; i <= num1 - 1; i++) {
                    printf("1 ");
                }
            }
        }
        printf("\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值