#include <bits/stdc++.h>
using namespace std;
void mycode();
const long long int mod = 998244353;
long long int ceil(long long int a, long long int b) { return (a + b - 1) / b; }
long long int min(long long int a, long long int b) {
  if (a > b)
    return b;
  else
    return a;
}
bool bit_check(long long int a, int i) {
  if ((a & ((long long)1 << (i - 1)))) return 1;
  return 0;
}
long long int bit_toggle(long long int a, int i) {
  return (a ^ ((long long)1 << (i - 1)));
}
long long int bit_sum(long long int a, int i) {
  return a + ((long long)1 << (i - 1));
}
long long int bit_sub(long long int a, int i) {
  return a - ((long long)1 << (i - 1));
}
long long int mod_power(long long int x, long long int y) {
  long long int p = mod;
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int power_of(long long int a, int b) {
  if (a == 0) return -1;
  return 1 + power_of(a / b, b);
}
long long power(long long int a, long long int b) {
  if (a == 1) return 1;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int main() {
  mycode();
  return 0;
}
void mycode() {
  int t;
  cin >> t;
  while (t--) {
    int n, a = 0, b = 0, k;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> k;
      if ((k & 1) != (i & 1)) {
        if (i & 1)
          a++;
        else
          b++;
      }
    }
    if (a == b)
      cout << a << '\n';
    else
      cout << -1 << '\n';
  }
}
