Palindrome lover
Bitmask
Basics of bit manipulation
Basic programming
Bit manipulation
Bit manipulation
Basics of bit manipulation
72.0% success
3,546 attempts
2s time
256MB memory
1024KB max code

Given an array of \(N\) integers

You have to transform the array, for every \(i (1 \leq i \leq N)\): \(a[i] = a[i] \%2\)

For example: if the given array is 3,4,5 then after the transformation the array will be 1,0,1


Your task is to convert the array into a palindrome and for that you can re-arrange the elements however you wish

Is it possible to convert the array into a palindrome?


Input :
The first line contains \(T\), the number of test cases \(1 \leq T \leq 10^3\)
The second line contains \(N\), the number of array elements \(1 \leq N \leq 10^5\)
The third line contains \(N\) integers, the array elements \(1 \leq a[i] \leq 10^9\)


Output:
For all test cases print \(1\) if the array can be converted into a palindrome or else print \(0\)

Examples
Input
2
3 
1 5 7
6
1 2 3 3 3 3
Output
1
0
Explanation

For test case 1, the array will be transformed into 1,1,1 after mod with 2,
The array is already a palindrome, so the output is 1

For test case 2, the array after transformation will be 1,0,1,1,1,1

Now no matter how you try to arrange them, it is impossible to convert the array into a palindrome,that's why the output is 0

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...