You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.

An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $i$ ($0 \le i \le n - 1$) the equality $i \bmod 2 = a[i] \bmod 2$ holds, where $x \bmod 2$ is the remainder of dividing $x$ by 2.

For example, the arrays [$0, 5, 2, 1$] and [$0, 17, 0, 3$] are good, and the array [$2, 4, 6, 7$] is bad, because for $i=1$, the parities of $i$ and $a[i]$ are different: $i \bmod 2 = 1 \bmod 2 = 1$, but $a[i] \bmod 2 = 4 \bmod 2 = 0$.

In one move, you can take any two elements of the array and swap them (these elements are not necessarily adjacent).

Find the minimum number of moves in which you can make the array $a$ good, or say that this is not possible.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases in the test. Then $t$ test cases follow.

Each test case starts with a line containing an integer $n$ ($1 \le n \le 40$) — the length of the array $a$.

The next line contains $n$ integers $a_0, a_1, \ldots, a_{n-1}$ ($0 \le a_i \le 1000$) — the initial array.


-----Output-----

For each test case, output a single integer — the minimum number of moves to make the given array $a$ good, or -1 if this is not possible.


-----Example-----
Input
4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0

Output
2
1
-1
0



-----Note-----

In the first test case, in the first move, you can swap the elements with indices $0$ and $1$, and in the second move, you can swap the elements with indices $2$ and $3$.

In the second test case, in the first move, you need to swap the elements with indices $0$ and $1$.

In the third test case, you cannot make the array good.

Difficulty: introductory

Starter code:

Solutions:


for _ in range(int(input())):
	n=int(input())
	a=list(map(int,input().split()))

	od=0
	ev=0

	for i in range(n):
		if(i&1):
			if(a[i]%2==0):
				od+=1
		else:
			if(a[i]&1):
				ev+=1

	if(od!=ev):
		print(-1)
	else:
		print(od)

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

import sys
INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

def solve():
  n, = I()
  a = I()
  count = [0, 0, 0]
  for i in range(n):
    if i % 2 == a[i] % 2:
      continue
    count[a[i] % 2] += 1
  if count[0] != count[1]:
    print(-1)
  else:
    print(count[0])

t, = I()
while t:
  t -= 1
  solve()

import sys
import random
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 rlinput():
    return list(map(int, input().split()))
def trinput():
    return tuple(rinput())

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

def YESNO(fl):
    if fl:
        print("NO")
    else:
        print("YES")
    
    
def main():   
    n = iinput() 
    #k = iinput() 
    #m = iinput() 
    #n = int(sys.stdin.readline().strip()) 
    #n, k = rinput()
    #n, m = rinput()
    #m, k = rinput()
    #n, k, m = rinput()
    #n, m, k = rinput()
    #k, n, m = rinput()
    #k, m, n = rinput() 
    #m, k, n = rinput()
    #m, n, k = rinput()
    #q = srlinput()
    q = rlinput()
    t = 0
    for i in range(n):
        q[i] %= 2
        if q[i] != i % 2:
            t += 1
    if sum(q) != n // 2:
        print(-1)
    else:
        print(t // 2)
    

    
    
            
            
    
    
    
    
for inytd in range(iinput()):
    main()

T = int(input())

for t in range(T):
    N = int(input())
    A = [int(_) for _ in input().split()]
    badE, badO = 0, 0
    for i, el in enumerate(A):
        if el%2 != i%2:
            if i%2:
                badO += 1
            else:
                badE += 1
    if badO != badE:
        print(-1)
    else:
        print(badO)


tests = int(input())
for _ in range(tests):
    n = int(input())
    sp = list(map(int, input().split()))
    ch = 0
    for i in sp:
        if i % 2 == 0:
            ch += 1
    if ch != n - n // 2:
        print(-1)
        continue
    count = 0
    for i in range(n):
        if i % 2 != sp[i] % 2:
            count += 1
    print(count // 2)


t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    badEven = 0
    badOdd = 0
    for i in range(n):
        if i % 2 != a[i] % 2 and i % 2 == 0:
            badEven += 1
        elif i % 2 != a[i] % 2 and i % 2 == 1:
            badOdd += 1
    if badEven == badOdd:
        print(badEven)
    else:
        print(-1)

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))

    l = []

    for i in range(n):
        if a[i] % 2 != i % 2:
            l.append(a[i])

    oc = sum(i % 2 for i in l)
    ec = len(l) - oc

    if oc != ec:
        print(-1)
        continue
    else:
        print(oc)

import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int,input().split()))
	o,e = 0,0
	for i in a:
		if i%2:
			o+=1
		else:
			e+=1
	if o!=e and e!=o+1:
		print (-1)
		continue
	count = 0
	for i in range(n):
		if i%2!=a[i]%2:
			count += 1
	print (count//2)

from collections import Counter, defaultdict

BS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def to_base(s, b):
    res = ""
    while s:
        res+=BS[s%b]
        s//= b
    return res[::-1] or "0"
alpha = "abcdefghijklmnopqrstuvwxyz"
from math import floor, ceil,pi

t = int(input())
for i in range(t):
    n = int(input())
    arr = list(map(int, input().split()))
    oddWrong = 0
    evenWrong = 0
    for i in range(len(arr)):
        if i%2==0:
            if arr[i]%2==1:
                evenWrong += 1
        else:
            if arr[i]%2==0:
                oddWrong += 1

    if oddWrong==evenWrong:
        print(oddWrong)
    else:
        print(-1)

t = int(input())

for case in range(t):
    n = int(input())
    a = [int(x) for x in input().split()]

    odd_wrong = 0
    even_wrong = 0

    for i, x in enumerate(a):
        if x % 2 == 0 and i % 2 == 1:
            even_wrong += 1

        if x % 2 == 1 and i % 2 == 0:
            odd_wrong += 1

    if odd_wrong == even_wrong:
        print(odd_wrong)
    else:
        print(-1)


for tc in range(int(input())):
    n = int(input())
    a = [int(s) for s in input().split()]

    cnt = [0, 0]
    for i, e in enumerate(a):
        if i % 2 != e % 2:
            cnt[i % 2] += 1

    if cnt[0] != cnt[1]:
        print(-1)
    else:
        print(cnt[0])


for __ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    c = 0
    d = 0
    for i in range(n):
        if a[i] % 2 != i % 2:
            if a[i] % 2 == 1:
                c += 1
            else:
                d += 1
    if c == d:
        print(c)
    else:
        print(-1)

def read_int():
    return int(input())


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


t = read_int()
for case_num in range(t):
    n = read_int()
    a = list(read_ints())
    o2e = 0
    e2o = 0
    for i in range(n):
        if i % 2 == 0 and a[i] % 2 != 0:
            o2e += 1
        if i % 2 != 0 and a[i] % 2 == 0:
            e2o += 1
    print(-1 if o2e != e2o else o2e)


for _ in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    e=0
    o=0
    for i in range(n):
        if i%2!=a[i]%2:
            if (i%2):
                e+=1
            else:
                o+=1
    if o==e:
        print(o)
    else:
        print(-1)

"""
Author: Q.E.D
Time: 2020-06-16 09:39:00
"""
T = int(input())
for _ in range(T):
    n = int(input())
    a = list(map(int, input().split()))
    odd = 0
    even = 0
    for i, x in enumerate(a):
        if i % 2 == 1 and  x % 2 == 0:
            odd += 1
        elif i % 2 == 0 and x % 2 == 1:
            even += 1
    if odd == even:
        ans = odd
    else:
        ans = -1
    print(ans)


import sys
import math
from math import factorial as f
from collections import defaultdict as dd
mod=1000000007
T=1
T=int(sys.stdin.readline())
for _ in range(T):
    n=int(input())
    l=list(map(int,input().split()))
    c1,c2=0,0
    for i in range(n):
        if(l[i]&1):
            if i&1==0:
                c1+=1
        else:
            if(i&1):
                c2+=1
    if c1!=c2:
        print(-1)
    else:
        print(c1)
        


for t in range(int(input())):
    n = int(input())
    a = [int(x) for x in input().split()]
    wrong0 = sum([1 if a[i]%2 != i%2 else 0 for i in range(n) if i%2==0])
    wrong1 = sum([1 if a[i]%2 != i%2 else 0 for i in range(n) if i%2==1])
    print(wrong0 if wrong0==wrong1 else -1)

q = int(input())
for _ in range(q):
    n = int(input())
    l = list(map(int,input().split()))
    zlep = 0
    zlen = 0
    for i in range(n):
        if i%2 == 0:
           zlep += (i-l[i])%2
        else:
            zlen += (i-l[i])%2
    if zlen == zlep:
        print(zlen)
    else:
        print(-1)

from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]

for _ in range(val()):
    n = val()
    a = li()
    ans = evens = odds = 0
    for i in range(n):
        if a[i]&1 == i&1:continue
        elif a[i]&1:odds += 1
        else:evens += 1
    if evens != odds:
        print(-1)
    else:
        print(evens)


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


'''
4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0
'''
for _ in range(int(input())):
    n = int(input())
    a = list(mi())

    o, e = 0,0
    for i in range(n):
        if i%2:
            if a[i]%2==0:
                o+=1
        else:
            if a[i]%2:
                e+=1
    if o==e:
        print(o)
    else:
        print (-1)

def help():
	n = int(input())
	arr = list(map(int,input().split(" ")))

	ev = []
	od = []

	for i in range(n):
		if(arr[i]%2==1):
			if(arr[i]%2!=i%2):
				od.append(i)
		else:
			if(arr[i]%2!=i%2):
				ev.append(i)
	if(len(ev)==len(od)):
		print(len(ev))
	else:
		print(-1)


for _ in range(int(input())):
	help()

t=int(input())
for i in range(t):
    n=int(input())
    a=[int(i) for i in input().split()]
    nch=0
    ch=0
    for i in range(n):
        if a[i]%2==0 and i%2==1:
            ch+=1
        elif a[i]%2==1 and i%2==0:
            nch+=1
    if nch!=ch:
        print(-1)
    else:
        print(ch)

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


for _ in range(int(input())):
    input()
    l = list(map(int, input().split()))
    e = 0
    o = 0
    for i in range(len(l)):
        if l[i] % 2 != i % 2:
            if i % 2 == 0:
                e += 1
            else:
                o += 1
    print(-1 if e != o else e)

n = int(input())

for _ in range(n):
    input()
    a = list(map(int, input().split()))
    c_e, c_n = 0, 0
    for i, x in enumerate(a):
        if i % 2 == 0 and x % 2 == 1:
            c_e += 1
        if i % 2 == 1 and x % 2 == 0:
            c_n += 1
    if c_e != c_n:
        print(-1)
    else:
        print(c_e)


for _ in range(int(input())):
    am = int(input())
    arr = list(map(int,input().split()))
    bad = [0,0]
    fl = False
    for i in range(am):
        if arr[i]&1 != i&1:
            bad[i&1]+=1
            fl = True
    if not fl:
        print(0)
    else:
        if bad[0]!=bad[1]:
            print(-1)
        else:
            print(bad[0])