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.
[{"code": "\n\nfor _ in range(int(input())):\n\tn=int(input())\n\ta=list(map(int,input().split()))\n\n\tod=0\n\tev=0\n\n\tfor i in range(n):\n\t\tif(i&1):\n\t\t\tif(a[i]%2==0):\n\t\t\t\tod+=1\n\t\telse:\n\t\t\tif(a[i]&1):\n\t\t\t\tev+=1\n\n\tif(od!=ev):\n\t\tprint(-1)\n\telse:\n\t\tprint(od)", "passed": true, "time": 0.26, "memory": 14308.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n=int(input())\n    a=list(map(int,input().split()))\n    c1,c2=0,0\n    for i in range(n):\n        if(i%2==0 and a[i]%2!=0):\n            c1+=1\n        if(i%2==1 and a[i]%2!=1):\n            c2+=1\n    if(c1!=c2):\n        print(-1)\n    else:\n        print(c1)", "passed": true, "time": 0.15, "memory": 14272.0, "status": "done"}, {"code": "import sys\nINF = 10**20\nMOD = 10**9 + 7\nI = lambda:list(map(int,input().split()))\nfrom math import gcd\nfrom math import ceil\nfrom collections import defaultdict as dd, Counter\nfrom bisect import bisect_left as bl, bisect_right as br\n\ndef solve():\n  n, = I()\n  a = I()\n  count = [0, 0, 0]\n  for i in range(n):\n    if i % 2 == a[i] % 2:\n      continue\n    count[a[i] % 2] += 1\n  if count[0] != count[1]:\n    print(-1)\n  else:\n    print(count[0])\n\nt, = I()\nwhile t:\n  t -= 1\n  solve()", "passed": true, "time": 0.15, "memory": 14132.0, "status": "done"}, {"code": "T = int(input())\n\nfor t in range(T):\n    N = int(input())\n    A = [int(_) for _ in input().split()]\n    badE, badO = 0, 0\n    for i, el in enumerate(A):\n        if el%2 != i%2:\n            if i%2:\n                badO += 1\n            else:\n                badE += 1\n    if badO != badE:\n        print(-1)\n    else:\n        print(badO)\n", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "tests = int(input())\nfor _ in range(tests):\n    n = int(input())\n    sp = list(map(int, input().split()))\n    ch = 0\n    for i in sp:\n        if i % 2 == 0:\n            ch += 1\n    if ch != n - n // 2:\n        print(-1)\n        continue\n    count = 0\n    for i in range(n):\n        if i % 2 != sp[i] % 2:\n            count += 1\n    print(count // 2)\n", "passed": true, "time": 0.17, "memory": 14124.0, "status": "done"}, {"code": "t = int(input())\nfor _ in range(t):\n    n = int(input())\n    a = list(map(int,input().split()))\n    badEven = 0\n    badOdd = 0\n    for i in range(n):\n        if i % 2 != a[i] % 2 and i % 2 == 0:\n            badEven += 1\n        elif i % 2 != a[i] % 2 and i % 2 == 1:\n            badOdd += 1\n    if badEven == badOdd:\n        print(badEven)\n    else:\n        print(-1)", "passed": true, "time": 0.24, "memory": 14300.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n = int(input())\n    a = list(map(int, input().split()))\n\n    l = []\n\n    for i in range(n):\n        if a[i] % 2 != i % 2:\n            l.append(a[i])\n\n    oc = sum(i % 2 for i in l)\n    ec = len(l) - oc\n\n    if oc != ec:\n        print(-1)\n        continue\n    else:\n        print(oc)", "passed": true, "time": 0.24, "memory": 14232.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\nfor nt in range(int(input())):\n\tn = int(input())\n\ta = list(map(int,input().split()))\n\to,e = 0,0\n\tfor i in a:\n\t\tif i%2:\n\t\t\to+=1\n\t\telse:\n\t\t\te+=1\n\tif o!=e and e!=o+1:\n\t\tprint (-1)\n\t\tcontinue\n\tcount = 0\n\tfor i in range(n):\n\t\tif i%2!=a[i]%2:\n\t\t\tcount += 1\n\tprint (count//2)", "passed": true, "time": 0.23, "memory": 14036.0, "status": "done"}, {"code": "from collections import Counter, defaultdict\n\nBS=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\ndef to_base(s, b):\n    res = \"\"\n    while s:\n        res+=BS[s%b]\n        s//= b\n    return res[::-1] or \"0\"\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\nfrom math import floor, ceil,pi\n\nt = int(input())\nfor i in range(t):\n    n = int(input())\n    arr = list(map(int, input().split()))\n    oddWrong = 0\n    evenWrong = 0\n    for i in range(len(arr)):\n        if i%2==0:\n            if arr[i]%2==1:\n                evenWrong += 1\n        else:\n            if arr[i]%2==0:\n                oddWrong += 1\n\n    if oddWrong==evenWrong:\n        print(oddWrong)\n    else:\n        print(-1)", "passed": true, "time": 0.22, "memory": 14132.0, "status": "done"}, {"code": "t = int(input())\n\nfor case in range(t):\n    n = int(input())\n    a = [int(x) for x in input().split()]\n\n    odd_wrong = 0\n    even_wrong = 0\n\n    for i, x in enumerate(a):\n        if x % 2 == 0 and i % 2 == 1:\n            even_wrong += 1\n\n        if x % 2 == 1 and i % 2 == 0:\n            odd_wrong += 1\n\n    if odd_wrong == even_wrong:\n        print(odd_wrong)\n    else:\n        print(-1)\n", "passed": true, "time": 0.15, "memory": 14088.0, "status": "done"}, {"code": "for tc in range(int(input())):\n    n = int(input())\n    a = [int(s) for s in input().split()]\n\n    cnt = [0, 0]\n    for i, e in enumerate(a):\n        if i % 2 != e % 2:\n            cnt[i % 2] += 1\n\n    if cnt[0] != cnt[1]:\n        print(-1)\n    else:\n        print(cnt[0])\n", "passed": true, "time": 0.16, "memory": 14188.0, "status": "done"}, {"code": "for __ in range(int(input())):\n    n = int(input())\n    a = list(map(int, input().split()))\n    c = 0\n    d = 0\n    for i in range(n):\n        if a[i] % 2 != i % 2:\n            if a[i] % 2 == 1:\n                c += 1\n            else:\n                d += 1\n    if c == d:\n        print(c)\n    else:\n        print(-1)", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "def read_int():\n    return int(input())\n\n\ndef read_ints():\n    return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n    n = read_int()\n    a = list(read_ints())\n    o2e = 0\n    e2o = 0\n    for i in range(n):\n        if i % 2 == 0 and a[i] % 2 != 0:\n            o2e += 1\n        if i % 2 != 0 and a[i] % 2 == 0:\n            e2o += 1\n    print(-1 if o2e != e2o else o2e)\n", "passed": true, "time": 0.23, "memory": 14228.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n=int(input())\n    a=list(map(int, input().split()))\n    e=0\n    o=0\n    for i in range(n):\n        if i%2!=a[i]%2:\n            if (i%2):\n                e+=1\n            else:\n                o+=1\n    if o==e:\n        print(o)\n    else:\n        print(-1)", "passed": true, "time": 0.25, "memory": 14308.0, "status": "done"}, {"code": "\"\"\"\nAuthor: Q.E.D\nTime: 2020-06-16 09:39:00\n\"\"\"\nT = int(input())\nfor _ in range(T):\n    n = int(input())\n    a = list(map(int, input().split()))\n    odd = 0\n    even = 0\n    for i, x in enumerate(a):\n        if i % 2 == 1 and  x % 2 == 0:\n            odd += 1\n        elif i % 2 == 0 and x % 2 == 1:\n            even += 1\n    if odd == even:\n        ans = odd\n    else:\n        ans = -1\n    print(ans)\n", "passed": true, "time": 0.15, "memory": 14164.0, "status": "done"}, {"code": "import sys\nimport math\nfrom math import factorial as f\nfrom collections import defaultdict as dd\nmod=1000000007\nT=1\nT=int(sys.stdin.readline())\nfor _ in range(T):\n    n=int(input())\n    l=list(map(int,input().split()))\n    c1,c2=0,0\n    for i in range(n):\n        if(l[i]&1):\n            if i&1==0:\n                c1+=1\n        else:\n            if(i&1):\n                c2+=1\n    if c1!=c2:\n        print(-1)\n    else:\n        print(c1)\n        \n", "passed": true, "time": 0.14, "memory": 14144.0, "status": "done"}, {"code": "for t in range(int(input())):\n    n = int(input())\n    a = [int(x) for x in input().split()]\n    wrong0 = sum([1 if a[i]%2 != i%2 else 0 for i in range(n) if i%2==0])\n    wrong1 = sum([1 if a[i]%2 != i%2 else 0 for i in range(n) if i%2==1])\n    print(wrong0 if wrong0==wrong1 else -1)", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "q = int(input())\nfor _ in range(q):\n    n = int(input())\n    l = list(map(int,input().split()))\n    zlep = 0\n    zlen = 0\n    for i in range(n):\n        if i%2 == 0:\n           zlep += (i-l[i])%2\n        else:\n            zlen += (i-l[i])%2\n    if zlen == zlep:\n        print(zlen)\n    else:\n        print(-1)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "def mi():\n    return map(int, input().split())\n\n\n'''\n4\n4\n3 2 7 6\n3\n3 2 6\n1\n7\n7\n4 9 2 1 18 3 0\n'''\nfor _ in range(int(input())):\n    n = int(input())\n    a = list(mi())\n\n    o, e = 0,0\n    for i in range(n):\n        if i%2:\n            if a[i]%2==0:\n                o+=1\n        else:\n            if a[i]%2:\n                e+=1\n    if o==e:\n        print(o)\n    else:\n        print (-1)", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "def help():\n\tn = int(input())\n\tarr = list(map(int,input().split(\" \")))\n\n\tev = []\n\tod = []\n\n\tfor i in range(n):\n\t\tif(arr[i]%2==1):\n\t\t\tif(arr[i]%2!=i%2):\n\t\t\t\tod.append(i)\n\t\telse:\n\t\t\tif(arr[i]%2!=i%2):\n\t\t\t\tev.append(i)\n\tif(len(ev)==len(od)):\n\t\tprint(len(ev))\n\telse:\n\t\tprint(-1)\n\n\nfor _ in range(int(input())):\n\thelp()", "passed": true, "time": 0.14, "memory": 14192.0, "status": "done"}, {"code": "t=int(input())\nfor i in range(t):\n    n=int(input())\n    a=[int(i) for i in input().split()]\n    nch=0\n    ch=0\n    for i in range(n):\n        if a[i]%2==0 and i%2==1:\n            ch+=1\n        elif a[i]%2==1 and i%2==0:\n            nch+=1\n    if nch!=ch:\n        print(-1)\n    else:\n        print(ch)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "t=1\nt=int(input())\nfor _ in range(t):\n\tn=int(input())\n\tarr=list(map(int,input().split()))\n\tl=[0,0]\n\tfor i in range(n):\n\t\tif arr[i]%2!=i%2:\n\t\t\tl[i%2]+=1\n\tif l[0]==l[1]:\n\t\tprint(l[0])\n\telse:\n\t\tprint(-1)\n", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    input()\n    l = list(map(int, input().split()))\n    e = 0\n    o = 0\n    for i in range(len(l)):\n        if l[i] % 2 != i % 2:\n            if i % 2 == 0:\n                e += 1\n            else:\n                o += 1\n    print(-1 if e != o else e)", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "n = int(input())\n\nfor _ in range(n):\n    input()\n    a = list(map(int, input().split()))\n    c_e, c_n = 0, 0\n    for i, x in enumerate(a):\n        if i % 2 == 0 and x % 2 == 1:\n            c_e += 1\n        if i % 2 == 1 and x % 2 == 0:\n            c_n += 1\n    if c_e != c_n:\n        print(-1)\n    else:\n        print(c_e)\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    am = int(input())\n    arr = list(map(int,input().split()))\n    bad = [0,0]\n    fl = False\n    for i in range(am):\n        if arr[i]&1 != i&1:\n            bad[i&1]+=1\n            fl = True\n    if not fl:\n        print(0)\n    else:\n        if bad[0]!=bad[1]:\n            print(-1)\n        else:\n            print(bad[0])", "passed": true, "time": 0.14, "memory": 14344.0, "status": "done"}]