#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  long long t;
  cin >> t;
  for (long long testcase = 0; testcase < (t); ++testcase) {
    long long n;
    cin >> n;
    long long isp = 0, idp = 0, zp = 0, op = 0;
    long long a[n];
    for (long long i = 0; i < (n); ++i) {
      cin >> a[i];
      if (a[i] % 2 != i % 2) {
        idp++;
        if (i % 2 == 0)
          zp++;
        else
          op++;
      }
    }
    if (idp % 2 == 0 and zp == op)
      cout << idp / 2 << "\n";
    else
      cout << "-1\n";
  }
  return 0;
}
