#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, o = 0, e = 0;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; ++i) {
    if (a[i] % 2 != i % 2) {
      if (a[i] % 2 == 0)
        e++;
      else
        o++;
    }
  }
  if (o == e) {
    cout << o << '\n';
  } else {
    cout << -1 << '\n';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
