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