#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int mpow(int base, int exp);
long long randGen(long long lower, long long upper) {
  return (rand() % (upper - lower + 1)) + lower;
}
long long dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
void solve() {
  int n;
  cin >> n;
  int a[n];
  int odd = 0, even = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2 == 0 && a[i] % 2 == 1)
      odd++;
    else if (i % 2 == 1 && a[i] % 2 == 0)
      even++;
  }
  if (odd == even) {
    cout << odd << "\n";
    return;
  }
  cout << "-1\n";
}
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    solve();
  }
  return 0;
}
int mpow(int base, int exp) {
  base %= MOD;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % MOD;
    base = ((long long)base * base) % MOD;
    exp >>= 1;
  }
  return result;
}
