#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
const long long INF = 9e18;
const long long N = 1000000007;
const double eps = 1e-9;
const auto start_time = std::chrono::high_resolution_clock::now();
void zark() {}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long ans = 0, e = 0;
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
    if ((a[i] & 1) && i % 2 == 0) ans++;
    e += !(a[i] & 1);
  }
  if (e != (n + 1) / 2)
    cout << "-1\n";
  else
    cout << ans << '\n';
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
  zark();
  return 0;
}
