#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
const long long N = 2e2 + 5;
long long n;
long long a[N];
void solve(long long id) {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long odd = 0, even = 0;
  long long oddind = 0, evenind = 0;
  for (long long i = 0; i < n; i++) {
    if (i % 2 != a[i] % 2) {
      if (i % 2) {
        oddind++;
        even++;
      } else {
        evenind++;
        odd++;
      }
    }
  }
  if (oddind == odd) {
    cout << odd << endl;
  } else
    cout << "-1" << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  cin >> t;
  for (long long i = 1; i <= t; i++) solve(i);
  return 0;
}
