#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n, t;
  cin >> n;
  int oddConflict = 0, evenConflict = 0;
  for (int i = 0; i < n; i += 1) {
    cin >> t;
    if (i % 2) {
      if (t % 2 == 0) evenConflict++;
    } else if (t % 2)
      oddConflict++;
  }
  if (oddConflict - evenConflict == 0) return oddConflict;
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int TC = 1;
  cin >> TC;
  for (int u = 1; u <= TC; u++) cout << solve() << '\n';
  return 0;
}
