#include <bits/stdc++.h>
long long exp(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % p) % p;
    x = (x * x) % p;
    y /= 2;
  }
  return res;
}
long long expo(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % ((long long)1e9 + 7)) % ((long long)1e9 + 7);
    x = (x * x) % ((long long)1e9 + 7);
    y /= 2;
  }
  return res;
}
long long sub(long long a, long long b) {
  return (a % ((long long)1e9 + 7) - b % ((long long)1e9 + 7) +
          ((long long)1e9 + 7)) %
         ((long long)1e9 + 7);
}
long long mul(long long a, long long b) {
  return ((a % ((long long)1e9 + 7)) * (b % ((long long)1e9 + 7)) +
          ((long long)1e9 + 7)) %
         ((long long)1e9 + 7);
}
long long inv(long long x) { return expo(x, ((long long)1e9 + 7) - 2); }
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  long long cnt = 0;
  long long o = 0;
  long long e = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = a[i] % 2;
    if (a[i] == 0) e++;
  }
  if (e == (n + 1) / 2) {
    for (long long i = 0; i < n; i++) {
      if (a[i] != i % 2) cnt++;
    }
    cout << (cnt + 1) / 2 << endl;
  } else
    cout << -1 << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long testcases;
  cin >> testcases;
  while (testcases--) solve();
  return 0;
}
